You are here

public static function YamlFormToggles::processCheckboxes in YAML Form 8

Processes a checkboxes form element.

Overrides Checkboxes::processCheckboxes

File

src/Element/YamlFormToggles.php, line 26

Class

YamlFormToggles
Provides a form element for toggles.

Namespace

Drupal\yamlform\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'] = 'yamlform_toggle';
    $element[$key] += array_intersect_key($element, YamlFormToggle::getDefaultProperties());
  }
  return $element;
}