You are here

public static function YamlFormElementStates::validateYamlFormElementStates in YAML Form 8

Validates form states element.

File

src/Element/YamlFormElementStates.php, line 476

Class

YamlFormElementStates
Provides a form element to edit an element's #states.

Namespace

Drupal\yamlform\Element

Code

public static function validateYamlFormElementStates(&$element, FormStateInterface $form_state, &$complete_form) {
  if (isset($element['states']['#value']) && is_string($element['states']['#value'])) {
    $states = Yaml::decode($element['states']['#value']);
  }
  else {
    $states = self::convertFormValuesToFormApiStates($element['states']['#value']);
  }
  $form_state
    ->setValueForElement($element, NULL);
  $form_state
    ->setValueForElement($element, $states);
}