You are here

public function YamlFormHandlerFormBase::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

File

src/Form/YamlFormHandlerFormBase.php, line 151

Class

YamlFormHandlerFormBase
Provides a base form for form handlers.

Namespace

Drupal\yamlform\Form

Code

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

  // The form handler configuration is stored in the 'settings' key in
  // the form, pass that through for validation.
  $settings = $form_state
    ->getValue('settings') ?: [];
  $handler_state = (new FormState())
    ->setValues($settings);
  $this->yamlformHandler
    ->validateConfigurationForm($form, $handler_state);

  // Process handler state form errors.
  $this
    ->processHandlerFormErrors($handler_state, $form_state);

  // Update the original form values.
  $form_state
    ->setValue('settings', $handler_state
    ->getValues());
}