protected function CropTypeForm::flagViolations in Crop API 8
Same name and namespace in other branches
- 8.2 src/Form/CropTypeForm.php \Drupal\crop\Form\CropTypeForm::flagViolations()
Flags violations for the current form.
Parameters
\Symfony\Component\Validator\ConstraintViolationListInterface $violations: The violations to flag.
array $form: A nested array of form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to CropTypeForm::flagViolations()
- CropTypeForm::validateForm in src/
Form/ CropTypeForm.php - Form validation handler.
File
- src/
Form/ CropTypeForm.php, line 148
Class
- CropTypeForm
- Form controller for crop type forms.
Namespace
Drupal\crop\FormCode
protected function flagViolations(ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
// Manually flag violations of fields not handled by the form display.
foreach ($violations
->getIterator() as $violation) {
if ($violation
->getPropertyPath() == 'aspect_ratio') {
$form_state
->setErrorByName('aspect_ratio', $violation
->getMessage());
}
if ($violation
->getPropertyPath() == 'id') {
$form_state
->setErrorByName('id', $violation
->getMessage());
}
}
}