Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Form Helper Dropdown when selected value is not in the options

$
0
0
Form helper - form drop down - we create an array of the options to appear in the drop down list. And then we can add a value to be the default 'selected value' in the drop down list.

For different reasons i have sometimes had the condition where i am passing a default value - but its not in the options array. And when that happens - even though i am passing a default value - the default value for the drop down becomes blank. And then if the form is updated the original values are lost.

So I know that I can check the options array, and see if the selected value is in there, and if its not then add it to the options array. I am doing that for some critical fields but its a lot of extra code per field. Has anyone run into this issue and come up with a solution?

Viewing all articles
Browse latest Browse all 14343

Trending Articles