public function ColorizedGmapConfigurationForm::validateForm in Colorized google maps block 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/ ColorizedGmapConfigurationForm.php, line 109
Class
- ColorizedGmapConfigurationForm
- Defines a form that configures forms module settings.
Namespace
Drupal\colorized_gmap\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$auth_method = $form_state
->getValue('colorized_gmap_auth_method');
if ($auth_method == 1 && empty($form_state
->getValue('colorized_gmap_api_key'))) {
$form_state
->setErrorByName('colorized_gmap_api_key', $this
->t('Google Places API Key is required.'));
}
if ($auth_method == 2 && empty($form_state
->getValue('colorized_gmap_client_id'))) {
$form_state
->setErrorByName('colorized_gmap_client_id', $this
->t('Client ID is required.'));
}
if ($auth_method == 2 && empty($form_state
->getValue('colorized_gmap_private_key'))) {
$form_state
->setErrorByName('colorized_gmap_private_key', $this
->t('Private/Signing Key is required.'));
}
}