I want to store values in session as like below
option => array (
['option_display] => array(
'color' => 'white',
'RAM' => '3gb'
),
['option_details'] => array (
'5' => '3'
'6' => '5'
) );
Above code is the options for product to choose color and RAM are the titles for the options and their values, In option_details array contains id for the above options. The option display array values are need to display in front end and option details array are need to store in db.
My code is
case 'radio':
echo $value->getTitle();
echo '<input type="hidden" name="option_display['.$value->getTitle().']" id="option_display_'.$value->getTitle().'" />';
echo '<p class="'.(($value->getIsRequire() == 1) ? 'required' : '').'">'.(($value->getIsRequire() == 1) ? '*Required Field' : '').'</p>';
foreach ($option as $values) {
echo '<div>
<input type="radio" name="option_value['.$value->getOptionId().']" value ="'.$values['option_type_id'].'" id="option_value_'.$value->getOptionId().'" />'.$values['title'].'
</div>';
}
break;
If i select the values the option details are coming but option display array has only option titles no values are coming because i cant select values in hidden field My ouput array is
option => array (['option_display] => array(
[color] =>
[RAM] =>
), ['option_details'] => array (
[5] => '3'
[6] => '5'
) );
How can get the values in both array when user selects the option.
You have to update value as user select the options ,
echo '<input type="hidden" name="option_display['.$value->getTitle().']" id="option_display_'.$value->getTitle().'" />';
To
echo '<input type="hidden" name="option_display['.$value->getTitle().']" id="option_display_'.$value->getTitle().'" value="user_selected_value" />';