You are here

public static function YamlFormEntitySelect::processSelect in YAML Form 8

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/YamlFormEntitySelect.php, line 20

Class

YamlFormEntitySelect
Provides a form element for a entity select menu.

Namespace

Drupal\yamlform\Element

Code

public static function processSelect(&$element, FormStateInterface $form_state, &$complete_form) {
  self::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;
}