I have 5 check-box. For each check-box, 5 radio buttons get generated. These radios value get saved to database. Now what I want is, when I select check-box, and if the selected check-box has some database value already saved in database, that radio button should show saved database value, mean to say, it should be shown selected. 5 check-box are like: 1. A 2. B 3. C 4. D 5. C
All check-box has radio options like: Male or Female
If(say) I choose "Male" for "A" and submit my form. when I again go to that form and choose "A", "male" radio button should be shown selected.
some code implementation:
foreach ($check-box-options as $key => $value) {
$form['radio_'.$key] = array(
'#type' => 'radios',
'#title' => t('abc'),
'#options' => $filter_radio_options,
'#default_value'=> ???,
'#states' => array(
'visible' => array(
':input[name="filter_criteria_options['.$key.']"]' => array('checked' => TRUE),
),
),
);
}
$check-box-options
is an array of check-box A,B,C,D,E. For each check-box, I have radios.
$serialized = unserialize($radio_buttons_database_values);
$serialized
contains all selected radio button values. If I replace $check-box-options
with $serialized
, I got correct radio button selected as default, but if I loop $serialized
as nested inside $check-box-options
, it is throwing last selected value from database for every check-box. I am not getting the exact problem with my code or approach.
Can anyone please help me understanding the exact problem behind this?
variable_get()
? Can we see how you save these values? Is it a settings form? Is it a node?