/**
  * {@inheritdoc}
  */
 public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 {
     // Never flag validation errors for the remove button.
     $clicked_button = end($form_state->getTriggeringElement()['#parents']);
     if ($clicked_button !== 'remove_button') {
         parent::flagErrors($items, $violations, $form, $form_state);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * Override the '%uri' message parameter, to ensure that 'internal:' URIs
  * show a validation error message that doesn't mention that scheme.
  */
 public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 {
     /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
     foreach ($violations as $offset => $violation) {
         $parameters = $violation->getParameters();
         if (isset($parameters['@uri'])) {
             $parameters['@uri'] = static::getUriAsDisplayableString($parameters['@uri']);
             $violations->set($offset, new ConstraintViolation($this->t($violation->getMessageTemplate(), $parameters), $violation->getMessageTemplate(), $parameters, $violation->getRoot(), $violation->getPropertyPath(), $violation->getInvalidValue(), $violation->getPlural(), $violation->getCode()));
         }
     }
     parent::flagErrors($items, $violations, $form, $form_state);
 }