public function EntityInlineForm::entityFormValidate in Inline Entity Form 8
Validates the entity form.
Parameters
array $entity_form: The entity form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the parent form.
Overrides InlineFormInterface::entityFormValidate
File
- src/
Form/ EntityInlineForm.php, line 244
Class
- EntityInlineForm
- Generic entity inline form handler.
Namespace
Drupal\inline_entity_form\FormCode
public function entityFormValidate(array &$entity_form, FormStateInterface $form_state) {
// Perform entity validation only if the inline form was submitted,
// skipping other requests such as file uploads.
$triggering_element = $form_state
->getTriggeringElement();
if (!empty($triggering_element['#ief_submit_trigger'])) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $entity_form['#entity'];
$this
->buildEntity($entity_form, $entity, $form_state);
$form_display = $this
->getFormDisplay($entity, $entity_form['#form_mode']);
$form_display
->validateFormValues($entity, $entity_form, $form_state);
$entity
->setValidationRequired(FALSE);
foreach ($form_state
->getErrors() as $name => $message) {
// $name may be unknown in $form_state and
// $form_state->setErrorByName($name, $message) may suppress the error message.
$form_state
->setError($triggering_element, $message);
}
}
}