function _webform_edit_grid in Webform 7.3
Same name and namespace in other branches
- 5.2 components/grid.inc \_webform_edit_grid()
- 5 components/grid.inc \_webform_edit_grid()
- 6.3 components/grid.inc \_webform_edit_grid()
- 6.2 components/grid.inc \_webform_edit_grid()
- 7.4 components/grid.inc \_webform_edit_grid()
Implements _webform_edit_component().
File
- components/
grid.inc, line 54 - Webform module grid component.
Code
function _webform_edit_grid($component) {
$form = array();
if (module_exists('options_element')) {
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Options'),
'#collapsible' => TRUE,
'#description' => t('Options to select across the top. Usually these are ratings such as "poor" through "excellent" or "strongly disagree" through "strongly agree".'),
'#attributes' => array(
'class' => array(
'webform-options-element',
),
),
'#element_validate' => array(
'_webform_edit_validate_options',
),
);
$form['options']['options'] = array(
'#type' => 'options',
'#options' => _webform_select_options_from_text($component['extra']['options'], TRUE),
'#optgroups' => FALSE,
'#default_value' => FALSE,
'#default_value_allowed' => FALSE,
'#optgroups' => FALSE,
'#key_type' => 'mixed',
'#key_type_toggle' => t('Customize option keys (Advanced)'),
'#key_type_toggled' => $component['extra']['custom_option_keys'],
);
$form['questions'] = array(
'#type' => 'fieldset',
'#title' => t('Questions'),
'#collapsible' => TRUE,
'#description' => t('Questions list down the side of the grid.'),
'#attributes' => array(
'class' => array(
'webform-options-element',
),
),
'#element_validate' => array(
'_webform_edit_validate_options',
),
);
$form['questions']['options'] = array(
'#type' => 'options',
'#options' => _webform_select_options_from_text($component['extra']['questions'], TRUE),
'#optgroups' => FALSE,
'#default_value' => FALSE,
'#default_value_allowed' => FALSE,
'#optgroups' => FALSE,
'#key_type' => 'mixed',
'#key_type_toggle' => t('Customize question keys (Advanced)'),
'#key_type_toggled' => $component['extra']['custom_question_keys'],
);
}
else {
$form['extra']['options'] = array(
'#type' => 'textarea',
'#title' => t('Options'),
'#default_value' => $component['extra']['options'],
'#description' => t('Options to select across the top. One option per line. <strong>Key-value pairs MUST be specified as "safe_key|Some readable option"</strong>. Use of only alphanumeric characters and underscores is recommended in keys.') . theme('webform_token_help'),
'#cols' => 60,
'#rows' => 5,
'#weight' => -3,
'#required' => TRUE,
'#wysiwyg' => FALSE,
'#element_validate' => array(
'_webform_edit_validate_select',
),
);
$form['extra']['questions'] = array(
'#type' => 'textarea',
'#title' => t('Questions'),
'#default_value' => $component['extra']['questions'],
'#description' => t('Questions list down the side of the grid. One question per line. <strong>Key-value pairs MUST be specified as "safe_key|Some readable option"</strong>. Use of only alphanumeric characters and underscores is recommended in keys.') . theme('webform_token_help'),
'#cols' => 60,
'#rows' => 5,
'#weight' => -2,
'#required' => TRUE,
'#wysiwyg' => FALSE,
'#element_validate' => array(
'_webform_edit_validate_select',
),
);
}
$form['display']['optrand'] = array(
'#type' => 'checkbox',
'#title' => t('Randomize Options'),
'#default_value' => $component['extra']['optrand'],
'#description' => t('Randomizes the order of options on the top when they are displayed in the form.'),
'#parents' => array(
'extra',
'optrand',
),
);
$form['display']['qrand'] = array(
'#type' => 'checkbox',
'#title' => t('Randomize Questions'),
'#default_value' => $component['extra']['qrand'],
'#description' => t('Randomize the order of the questions on the side when they are displayed in the form.'),
'#parents' => array(
'extra',
'qrand',
),
);
return $form;
}