You are here

function webform_component_select in Webform 6.3

Same name and namespace in other branches
  1. 7.4 includes/webform.components.inc \webform_component_select()
  2. 7.3 includes/webform.components.inc \webform_component_select()

A Form API process function to expand a component list into checkboxes.

2 string references to 'webform_component_select'
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 936
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' => check_plain($label),
      '#type' => 'checkbox',
      '#default_value' => array_search($key, $element['#value']) !== FALSE,
      '#return_value' => $key,
      '#parents' => array_merge($element['#parents'], array(
        $key,
      )),
      '#indent' => $indents,
    );
  }
  $element['#type'] = 'webform_component_select';
  $element['#theme'] = 'webform_component_select';
  return $element;
}