function FormOperations::validateDefaultWorkspace

Same name in other branches
  1. 9 core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::validateDefaultWorkspace()
  2. 8.9.x core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::validateDefaultWorkspace()
  3. 11.x core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::validateDefaultWorkspace()

Validation handler which sets a validation error for all unsupported forms.

File

core/modules/workspaces/src/FormOperations.php, line 102

Class

FormOperations
Defines a class for reacting to form operations.

Namespace

Drupal\workspaces

Code

public static function validateDefaultWorkspace(array &$form, FormStateInterface $form_state) {
    if ($form_state->get('workspace_safe') !== TRUE) {
        $form_state->setError($form, new TranslatableMarkup('This form can only be submitted in the default workspace.'));
    }
}

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