public function ContentEntityForm::validateForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::validateForm()
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
2 calls to ContentEntityForm::validateForm()
- MessageForm::validateForm in core/
modules/ contact/ src/ MessageForm.php - 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…
- TermForm::validateForm in core/
modules/ taxonomy/ src/ TermForm.php - 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…
3 methods override ContentEntityForm::validateForm()
- ContentEntityConfirmFormBase::validateForm in core/
lib/ Drupal/ Core/ Entity/ ContentEntityConfirmFormBase.php - 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…
- MessageForm::validateForm in core/
modules/ contact/ src/ MessageForm.php - 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…
- TermForm::validateForm in core/
modules/ taxonomy/ src/ TermForm.php - 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…
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityForm.php, line 96 - Contains \Drupal\Core\Entity\ContentEntityForm.
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;
}