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?
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?