You are here

public function SettingsWebformHandler::validateConfigurationForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformHandler/SettingsWebformHandler.php \Drupal\webform\Plugin\WebformHandler\SettingsWebformHandler::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/SettingsWebformHandler.php, line 248

Class

SettingsWebformHandler
Webform submission settings handler.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

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

  // Make sure custom settings are valid.
  $custom = $form_state
    ->getValue('custom');
  if ($unknown_custom_settings = array_diff_key($custom, Webform::getDefaultSettings())) {
    $t_args = [
      '%name' => WebformArrayHelper::toString(array_keys($unknown_custom_settings)),
    ];
    $form_state
      ->setErrorByName('custom', $this
      ->t('Unknown custom %name setting(s).', $t_args));
  }
}