public function YamlFormSubmissionDevelGenerate::validateForm in YAML Form 8
Custom validation handler.
File
- src/
Plugin/ DevelGenerate/ YamlFormSubmissionDevelGenerate.php, line 166
Class
- YamlFormSubmissionDevelGenerate
- Provides a YamlFormSubmissionDevelGenerate plugin.
Namespace
Drupal\yamlform\Plugin\DevelGenerateCode
public function validateForm(array $form, FormStateInterface $form_state) {
$yamlform_ids = array_filter($form_state
->getValue('yamlform_ids'));
// Let default form validation handle requiring form ids.
if (empty($yamlform_ids)) {
return;
}
$entity_type = $form_state
->getValue('entity-type');
$entity_id = $form_state
->getValue('entity-id');
if ($entity_type || $entity_id) {
if ($error = $this
->validateEntity($yamlform_ids, $entity_type, $entity_id)) {
$form_state
->setErrorByName('entity_type', $error);
}
}
}