You are here

public static function WebformToggles::processCheckboxes in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_toggles/src/Element/WebformToggles.php \Drupal\webform_toggles\Element\WebformToggles::processCheckboxes()

Processes a checkboxes form element.

Overrides Checkboxes::processCheckboxes

File

modules/webform_toggles/src/Element/WebformToggles.php, line 26

Class

WebformToggles
Provides a webform element for toggles.

Namespace

Drupal\webform_toggles\Element

Code

public static function processCheckboxes(&$element, FormStateInterface $form_state, &$complete_form) {
  $element = parent::processCheckboxes($element, $form_state, $complete_form);

  // Convert checkboxes to toggle elements.
  foreach (Element::children($element) as $key) {
    $element[$key]['#type'] = 'webform_toggle';
    $element[$key] += array_intersect_key($element, WebformToggle::getDefaultProperties());
  }
  return $element;
}