Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 {
     // Manually flag violations of fields not handled by the form display. This
     // is necessary as entity form displays only flag violations for fields
     // contained in the display.
     $field_names = array('label', 'machine_name');
     foreach ($violations->getByFields($field_names) as $violation) {
         list($field_name) = explode('.', $violation->getPropertyPath(), 2);
         $form_state->setErrorByName($field_name, $violation->getMessage());
     }
     parent::flagViolations($violations, $form, $form_state);
 }