function WorkspaceForm::flagViolations

Same name in other branches
  1. 9 core/modules/workspaces/src/Form/WorkspaceForm.php \Drupal\workspaces\Form\WorkspaceForm::flagViolations()
  2. 8.9.x core/modules/workspaces/src/Form/WorkspaceForm.php \Drupal\workspaces\Form\WorkspaceForm::flagViolations()
  3. 10 core/modules/workspaces/src/Form/WorkspaceForm.php \Drupal\workspaces\Form\WorkspaceForm::flagViolations()

Overrides ContentEntityForm::flagViolations

File

core/modules/workspaces/src/Form/WorkspaceForm.php, line 83

Class

WorkspaceForm
Form controller for the workspace edit forms.

Namespace

Drupal\workspaces\Form

Code

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 = [
        'label',
        'id',
    ];
    foreach ($violations->getByFields($field_names) as $violation) {
        [
            $field_name,
        ] = explode('.', $violation->getPropertyPath(), 2);
        $form_state->setErrorByName($field_name, $violation->getMessage());
    }
    parent::flagViolations($violations, $form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.