public function ContextConfigure::validateForm in Chaos Tool Suite (ctools) 8.3
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/ ContextConfigure.php, line 156
Class
Namespace
Drupal\ctools\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// If these are not equal, then we're adding a new context and should not override an existing context.
if ($form_state
->getValue('machine_name') != $form_state
->getValue('context_id')) {
$machine_name = $form_state
->getValue('machine_name');
$cached_values = $this->tempstore
->get($this->tempstore_id)
->get($this->machine_name);
if (!empty($this
->getContexts($cached_values)[$machine_name])) {
$form_state
->setError($form['machine_name'], $this
->t('That machine name is in use by another context definition.'));
}
}
}