You are here

public function SensorForm::validateForm in Monitoring 8

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/SensorForm.php, line 234
Contains \Drupal\monitoring\Form\SensorForm.

Class

SensorForm
Sensor settings form controller.

Namespace

Drupal\monitoring\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  /** @var \Drupal\monitoring\SensorConfigInterface $sensor_config */
  $sensor_config = $this->entity;

  /** @var \Drupal\monitoring\SensorPlugin\SensorPluginInterface $plugin */
  if ($sensor_config
    ->isNew()) {
    $plugin_id = $form_state
      ->getValue('plugin_id');
    $plugin = monitoring_sensor_manager()
      ->createInstance($plugin_id, array(
      'sensor_config' => $this->entity,
    ));
  }
  else {
    $plugin = $sensor_config
      ->getPlugin();
  }
  $plugin
    ->validateConfigurationForm($form, $form_state);
  if ($this->entity
    ->isNumeric()) {
    $this
      ->validateThresholdsForm($form, $form_state);
  }
}