function webform_component_select in Webform 7.4
Same name and namespace in other branches
- 6.3 includes/webform.components.inc \webform_component_select()
- 7.3 includes/webform.components.inc \webform_component_select()
A Form API process function to expand a component list into checkboxes.
4 string references to 'webform_component_select'
- webform_analysis_components_form in includes/
webform.report.inc - Form for selecting which components should be shown on the analysis page.
- webform_configure_form in includes/
webform.pages.inc - Main configuration form for editing a webform node.
- webform_email_edit_form in includes/
webform.emails.inc - Form for configuring an e-mail setting and template.
- webform_results_download_form in includes/
webform.report.inc - Form to configure the download of CSV files.
File
- includes/
webform.components.inc, line 1099 - Webform module component handling.
Code
function webform_component_select($element) {
// Split the select list into checkboxes.
foreach ($element['#options'] as $key => $label) {
$label_length = strlen($label);
$label = preg_replace('/^(\\-)+/', '', $label);
$indents = $label_length - strlen($label);
$element[$key] = array(
'#title' => $label,
'#type' => 'checkbox',
'#default_value' => array_search($key, $element['#value']) !== FALSE,
'#return_value' => $key,
'#parents' => array_merge($element['#parents'], array(
$key,
)),
'#indent' => $indents,
);
}
$element['#theme_wrappers'] = array();
$element['#type'] = 'webform_component_select';
$element['#theme'] = 'webform_component_select';
$element['#attached'] = array(
'library' => array(
array(
'webform',
'admin',
),
array(
'system',
'drupal.collapse',
),
),
'js' => array(
'misc/tableselect.js' => array(),
),
);
return $element;
}