public function ActionWebformHandler::validateConfigurationForm in Webform 6.x
Same name and namespace in other branches
- 8.5 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 216
Class
- ActionWebformHandler
- Webform submission action handler.
Namespace
Drupal\webform\Plugin\WebformHandlerCode
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,
]));
}
}
}