public function GeolocationMapWidgetBase::flagErrors in Geolocation Field 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/GeolocationMapWidgetBase.php \Drupal\geolocation\Plugin\Field\FieldWidget\GeolocationMapWidgetBase::flagErrors()
Reports field-level validation errors against actual form elements.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values.
\Symfony\Component\Validator\ConstraintViolationListInterface $violations: A list of constraint violations to flag.
array $form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Overrides WidgetBase::flagErrors
File
- src/
Plugin/ Field/ FieldWidget/ GeolocationMapWidgetBase.php, line 105
Class
- GeolocationMapWidgetBase
- Map widget base.
Namespace
Drupal\geolocation\Plugin\Field\FieldWidgetCode
public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
foreach ($violations as $violation) {
if ($violation
->getMessageTemplate() == 'This value should not be null.') {
$form_state
->setErrorByName($items
->getName(), $this
->t('No location has been selected yet for required field %field.', [
'%field' => $items
->getFieldDefinition()
->getLabel(),
]));
}
}
parent::flagErrors($items, $violations, $form, $form_state);
}