diff --git a/components/select.inc b/components/select.inc index def3ef1..143b37f 100644 --- a/components/select.inc +++ b/components/select.inc @@ -166,7 +166,7 @@ function _webform_edit_select($component) { '#type' => 'checkbox', '#title' => t('Listbox'), '#default_value' => $component['extra']['aslist'], - '#description' => t('Check this option if you want the select component to be of listbox type instead of radio buttons or checkboxes.'), + '#description' => t('Check this option if you want the select component to be of listbox type instead of radio buttons or checkboxes. Will be checked automatically if you are using option groups.'), '#parents' => array('extra', 'aslist'), ); $form['display']['optrand'] = array( diff --git a/includes/webform.components.inc b/includes/webform.components.inc index 24f0082..1bf30f6 100644 --- a/includes/webform.components.inc +++ b/includes/webform.components.inc @@ -624,6 +624,16 @@ function webform_component_edit_form_validate($form, &$form_state) { * Submit handler for webform_component_edit_form(). */ function webform_component_edit_form_submit($form, &$form_state) { + // If it is a select component and the options include option groups, set aslist. + if ($form_state['values']['type'] === 'select' && !empty($form_state['values']['extra']['items'])) { + foreach (_webform_select_options_from_text($form_state['values']['extra']['items']) as $option) { + if (is_array($option)) { + $form_state['values']['extra']['aslist'] = 1; + break; + } + } + } + // Ensure a webform record exists. $node = node_load($form_state['values']['nid']); webform_ensure_record($node);