php - CakePHP 2 form fields with same name -
i have form select user select / occupation, it`s not listed there can write on text field bellow.
the data saves corretly, text field, it`s last one, believe.
i using same name both field, saves this.
$this->data['student']['occupation']
if user find option on select , leaves text field empty data database empty.
how can save data field has value set?
thanks.
you need change name first:
in form can put select name "occupation" , textfield name "occupation2".
then in controller can that:
$this->data["student"]["occupation"] = $this->data["student"]["occupation2"] == "" ? $this->data["student"]["occupation"] : $this->data["student"]["occupation2"];
this verify if textfield empty, if empty use select list option else use textfield value.
Comments
Post a Comment