You are here

public function YamlFormEntityForm::validateForm in YAML Form 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormBase::validateForm

1 call to YamlFormEntityForm::validateForm()
YamlFormUiEntityForm::validateForm in modules/yamlform_ui/src/YamlFormUiEntityForm.php
Form validation handler.
1 method overrides YamlFormEntityForm::validateForm()
YamlFormUiEntityForm::validateForm in modules/yamlform_ui/src/YamlFormUiEntityForm.php
Form validation handler.

File

src/YamlFormEntityForm.php, line 207

Class

YamlFormEntityForm
Base for controller for form.

Namespace

Drupal\yamlform

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  // Validate elements YAML.
  if ($messages = $this->elementsValidator
    ->validate($this
    ->getEntity())) {
    $form_state
      ->setErrorByName('elements');
    foreach ($messages as $message) {
      drupal_set_message($message, 'error');
    }
  }
}