public function ClusterForm::validateForm in Elasticsearch Connector 8.2
Same name and namespace in other branches
- 8.7 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::validateForm()
- 8 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::validateForm()
- 8.5 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::validateForm()
- 8.6 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::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/ ClusterForm.php, line 219 - Contains Drupal\elasticsearch_connector\Form.
Class
- ClusterForm
- Provides a form for the Cluster entity.
Namespace
Drupal\elasticsearch_connector\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$values = $form_state
->getValues();
// TODO: Check for valid URL when we are submitting the form.
// Set default cluster.
$default = Cluster::getDefaultCluster();
if (empty($default) && !$values['default']) {
$default = Cluster::setDefaultCluster($values['cluster_id']);
}
elseif ($values['default']) {
$default = Cluster::setDefaultCluster($values['cluster_id']);
}
if ($values['default'] == 0 && !empty($default) && $default == $values['cluster_id']) {
drupal_set_message(t('There must be a default connection. %name is still the default
connection. Please change the default setting on the cluster you wish
to set as default.', array(
'%name' => $values['name'],
)), 'warning');
}
}