You are here

public function ActionWebformHandler::validateConfigurationForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformHandler/ActionWebformHandler.php \Drupal\webform\Plugin\WebformHandler\ActionWebformHandler::validateConfigurationForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides WebformHandlerBase::validateConfigurationForm

File

src/Plugin/WebformHandler/ActionWebformHandler.php, line 236

Class

ActionWebformHandler
Webform submission action handler.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->hasAnyErrors()) {
    return;
  }

  // Validate data element keys.
  $elements = $this
    ->getWebform()
    ->getElementsInitializedFlattenedAndHasValue();
  $data = Yaml::decode($form_state
    ->getValue('data')) ?: [];
  foreach ($data as $key => $value) {
    if (!isset($elements[$key])) {
      $form_state
        ->setErrorByName('data', $this
        ->t('%key is not valid element key.', [
        '%key' => $key,
      ]));
    }
  }
}