I'm trying to make a step form which redirects to a special form depending on a radio button option chosen by the user.
My form always go to the default option value. I think I'm doing it wrong with the $form_state['storage'] getting the selected option.
function multiform_second_form(&$form, &$form_state) {
$values = $form_state['values'];
$form_state['rebuild'] = TRUE;
$options = array(
'0' => t('Simple'),
'1' => t('Multiple'),
'2' => t('Custom'),
);
$form['qtype'] = array(
'#type' => 'radios',
'#title' => t('question'),
'#options' => $options,
'#description' => t('Chose a question type.'),
'#default_value' => $options['0'],
);
$option_value = $form['qtype']['options'];
$form_state['storage'] = array(
'qtype' => $option_value,
);
$form['next'] = array(
'#type' => 'submit',
'#value' => t('Next step'),
);
$form['#submit'][] = 'multiform_second_form_submit';
return $form;
}
function multiform_second_form_submit($form, &$form_state) {
$values = $form_state['values'];
$form_state['rebuild'] = TRUE;
if (isset($values['next']) && $values['op'] == $values['next']) {
switch ($form_state['storage']['qtype']) {
case 0:
$form_state['storage']['step'] = 'multiform_qsimple_form';
break;
case 1:
$form_state['storage']['step'] = 'multiform_qmultiple_form';
break;
case 2:
$form_state['storage']['step'] = 'multiform_qcustom_form';
break;
}
}
}
If somebody can give me some advices, it would be really great !