You are here

public function RestExampleClientDelete::validateForm in Examples for Developers 3.x

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

modules/rest_example/src/Form/RestExampleClientDelete.php, line 74

Class

RestExampleClientDelete
Delete a new node on a remote Drupal site.

Namespace

Drupal\rest_example\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (is_null($form_state
    ->get('node_id')) || !is_numeric($form_state
    ->get('node_id'))) {
    $form_state
      ->setErrorByName('delete', $this
      ->t('The ID passed in the URL is not an integer'));
  }
}