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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -