You are here

public static function WebformTermSelect::processSelect in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Element/WebformTermSelect.php \Drupal\webform\Element\WebformTermSelect::processSelect()

Processes a select list form element.

This process callback is mandatory for select fields, since all user agents automatically preselect the first available option of single (non-multiple) select lists.

Parameters

array $element: The form element to process.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

Return value

array The processed element.

Overrides Select::processSelect

See also

_form_validate()

File

src/Element/WebformTermSelect.php, line 33

Class

WebformTermSelect
Provides a webform element for a term select menu.

Namespace

Drupal\webform\Element

Code

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

  // Must convert this element['#type'] to a 'select' to prevent
  // "Illegal choice %choice in %name element" validation error.
  // @see \Drupal\Core\Form\FormValidator::performRequiredValidation
  $element['#type'] = 'select';
  return $element;
}