You are here

public function GrantsForm::validateForm in Nodeaccess 8

Same name and namespace in other branches
  1. 8.2 src/Form/GrantsForm.php \Drupal\nodeaccess\Form\GrantsForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/GrantsForm.php, line 292

Class

GrantsForm
Builds the configuration form.

Namespace

Drupal\nodeaccess\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $uids = $form_state
    ->getValue('uid');

  // Delete unkept users.
  if (!empty($uids) && is_array($uids)) {
    foreach ($uids as $uid => $row) {
      if (!$row['keep']) {
        unset($uids[$uid]);
      }
    }
    $form_state
      ->setValue('uid', $uids);
  }
}