function Role::validateOptionsForm

Same name in other branches
  1. 9 core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::validateOptionsForm()
  2. 8.9.x core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::validateOptionsForm()
  3. 11.x core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::validateOptionsForm()

Overrides PluginBase::validateOptionsForm

File

core/modules/user/src/Plugin/views/access/Role.php, line 119

Class

Role
Access plugin that provides role-based access control.

Namespace

Drupal\user\Plugin\views\access

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
    $role = $form_state->getValue([
        'access_options',
        'role',
    ]);
    $role = array_filter($role);
    if (!$role) {
        $form_state->setError($form['role'], $this->t('You must select at least one role if type is "by role"'));
    }
    $form_state->setValue([
        'access_options',
        'role',
    ], $role);
}

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