In Webform 2, I managed to create a list of radiobuttons with date components for each option. I did this by creating a 'radios'-element for each option, grouping them with the attribute #parents.
Example code:

$form['option_one'] = array(
    '#type' => 'radios',
    '#options' => array('0' => t("Exact date:")),
    '#weight' => 22,
    '#parents' => array('mygroup'),
);

$form['option_one_date'] = array(
    '#type' => 'date_select',
    '#attributes' => array('class'=>'marginleft-20'),
    '#date_format' => 'd-F-Y',
    '#date_year_range' => '0:+5',
    '#date_label_position' => 'none',
    '#weight' => 23,
);

$form['option_two'] = array(
    '#type' => 'radios',
    '#options' => array('1' => t("Approximately:")),
    '#weight' => 24,
    '#parents' => array('mygroup'),
);

$form['option_two_date'] = array(
    '#type' => 'date_select',
    '#attributes' => array('class'=>'marginleft-20'),
    '#date_format' => 'd-F-Y',
    '#date_year_range' => '0:+5',
    '#date_label_position' => 'none',
    '#weight' => 25,
);

$form['option_three'] = array(
    '#type' => 'radios',
    '#options' => array('2' => t("I'm not sure")),
    '#weight' => 26,
    '#parents' => array('mygroup'),
);

Look at the attachment to see the result of this code.

In Webform 3.2, it seems like the possibility to group items through #parents is not possible anymore.
How can I achieve this in Webform 3.2?

CommentFileSizeAuthor
webform2-date-inside-list.jpg9.21 KBadriaanm

Comments

quicksketch’s picture

I'm not sure how you're doing this creation of elements, theming, hook_form_alter(), PHP in a textarea? I generally do not provide support on how to write custom code in the Webform issue queue.

adriaanm’s picture

I have a modules that provides a block. The block prints this form variable using drupal_get_form.

adriaanm’s picture

It looks like this would we possible if Field Key is not required to be unique for select options with only one option.

In that way, you could define multiple "select options"-fields with the same field key, resulting in a multiple radios-element with the same parents.

quicksketch’s picture

If wanting to do the layout of your form in a custom manner, you should theme your form as described in THEMING.txt. Then you can drupal_render() out the individual radio buttons and date fields.

quicksketch’s picture

Status: Active » Closed (fixed)