You are here

public static function YamlFormRoles::processCheckboxes in YAML Form 8

Processes a checkboxes form element.

Overrides Checkboxes::processCheckboxes

File

src/Element/YamlFormRoles.php, line 31

Class

YamlFormRoles
Provides a roles entity reference form element.

Namespace

Drupal\yamlform\Element

Code

public static function processCheckboxes(&$element, FormStateInterface $form_state, &$complete_form) {
  $element['#options'] = array_map('\\Drupal\\Component\\Utility\\Html::escape', user_role_names());

  // Check if anonymous is included.
  if (empty($element['#include_anonymous'])) {
    unset($element['#options']['anonymous']);
  }
  $element['#attached']['library'][] = 'yamlform/yamlform.element.roles';
  $element['#attributes']['class'][] = 'js-yamlform-roles-role';
  return parent::processCheckboxes($element, $form_state, $complete_form);
}