set_radio() pre-populate problems |
[eluser]Unknown[/eluser]
I am trying to set a radio button as selected from the database but it isn't working. This is the code I am using: Code: <input type="radio" name="volunteer_applied_c" value="Yes" <?php echo set_radio('volunteer_applied_c', 'Yes', $application_data['volunteer_applied_c'] == 'Yes'); ?>>Yes I have verified that $application_data['volunteer_applied_c'] does contain the value of "Yes". What am I missing?
[eluser]Armchair Samurai[/eluser]
My guess is you need to explicitly set the boolean. Code: <input type="radio" name="volunteer_applied_c" value="Yes" <?php echo set_radio('volunteer_applied_c', 'Yes', ($application_data['volunteer_applied_c'] == 'Yes') ? TRUE : FALSE); ?>>Yes
[eluser]Unknown[/eluser]
Hmm, no dice. It works for validation to pre-populate but it doesn't load the db value on the first load. edit: i ended up using a solution like this from here: Code: <?php $options = array( If validation rules are set for the field then it will update the value from the submission after being pre-populated by the database value, $application_data['volunteer_applied_c'] |
Welcome Guest, Not a member yet? Register Sign In |