public function AssignOwnerNode::validate

Form validation handler.

Parameters

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

array $form_state: An associative array containing the current state of the form.

Overrides ConfigurableActionBase::validate

File

drupal/core/modules/node/lib/Drupal/node/Plugin/Action/AssignOwnerNode.php, line 121
Contains \Drupal\node\Plugin\Action\AssignOwnerNode.

Class

AssignOwnerNode
Assigns ownership of a node to a user.

Namespace

Drupal\node\Plugin\Action

Code

public function validate(array &$form, array &$form_state) {
  $exists = (bool) $this->connection
    ->queryRange('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(
    ':name' => $form_state['values']['owner_name'],
  ))
    ->fetchField();
  if (!$exists) {
    form_set_error('owner_name', t('Enter a valid username.'));
  }
}