public function ContentEntityForm::validateForm
public ContentEntityForm::validateForm(array &$form, FormStateInterface $form_state)
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level validation handler, otherwise an exception will be thrown.
Overrides FormBase::validateForm
File
- core/lib/Drupal/Core/Entity/ContentEntityForm.php, line 91
Class
- ContentEntityForm
- Entity form variant for content entity types.
Namespace
Drupal\Core\EntityCode
public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->buildEntity($form, $form_state); $violations = $entity->validate(); // Remove violations of inaccessible fields and not edited fields. $violations ->filterByFieldAccess($this->currentUser()) ->filterByFields(array_diff(array_keys($entity->getFieldDefinitions()), $this->getEditedFieldNames($form_state))); $this->flagViolations($violations, $form, $form_state); // The entity was validated. $entity->setValidationRequired(FALSE); $form_state->setTemporaryValue('entity_validated', TRUE); return $entity; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityForm.php/function/ContentEntityForm::validateForm/8.1.x