When I have a radio form item where it isn't applicable to define a default_value then all form items that depend on the radio are shown regardless of their dependency values. Upon selecting an option in the radio the dependency works like expected (items with different dependency values are hidden).
In case I haven't used dependent correctly - here are the form items:
$form['source'] = array(
'#type' => 'radios',
'#title' => t('Choose the object'),
// Often $form_state['taglist']->source['source'] is not set so default_value is not present.
'#default_value' => $form_state['taglist']->source['source'] ? $form_state['taglist']->source['source'] : NULL,
'#options' => $options['source'],
);
foreach ($options['source'] as $viewname) {
$form[$viewname] = array(
'#type' => 'select',
'#title' => t('Displays for view !viewname', array('!viewname' => $viewname)),
'#default_value' => $form_state['taglist']->source['display'] ? $form_state['taglist']->source['display'] : 'default',
'#options' => $options['display'][$viewname],
// Works when an option is selected in the radio form 'source'.
'#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:source' => array($viewname)),
);
}
Comments
Comment #1
Roi Danton commentedProblem was related to ctools. I've written a patch to fix it. Works in my case (also tested with other dependencies using checkboxes). Patch is against Head.
Comment #2
Benwick commentedThanx Roi it's cool 15 characters patch, works fine for me.
I found and "anomaly" about #654218: Dependent: Form's fieldset don't hide, however radios and checkboxes don't shown
Please take a look at it!
Comment #3
Roi Danton commentedSince the patch works for Benwick and I haven't encountered any problems with it yet either (using it for Linodef) I change issue status.
Comment #4
merlinofchaos commentedLooks good to me. Thanks for finding and fixing this one. I wasn't looking forward to having to hunt this one down.
Comment #6
eojthebraveLooks like this got fixed in 7.x but not 6.x.
Comment #7
mimrock commentedActually, this patch is not fixing the real issue. It may work as a hack, but the real source of the bug is the wrong implementation of inArray function in dependent.js
I submit a patch for the 6x-1.8 version, feel free to use it.
Comment #9
mimrock commentedThis issue has been already fixed in an other thread and the patch has been committed. I'm not a maintainer of ctools but I think we can close this issue.
http://drupal.org/node/941584