public function LdapUserMappingBaseForm::validateForm in Lightweight Directory Access Protocol (LDAP) 8.4
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
- ldap_user/
src/ Form/ LdapUserMappingBaseForm.php, line 109
Class
- LdapUserMappingBaseForm
- Provides the form to configure user configuration and field mapping.
Namespace
Drupal\ldap_user\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) : void {
$values = $form_state
->getValues();
foreach ($values['mappings'] as $key => $mapping) {
if (isset($mapping['configured_mapping']) && $mapping['configured_mapping'] == 1) {
// Check that the source is not empty for the selected field to sync
// to Drupal.
if (!empty($mapping['source']) && empty($mapping['target'])) {
$formElement = $form['mappings'][$key];
$form_state
->setError($formElement, $this
->t('Missing attribute'));
}
}
}
$processed_mappings = $this
->syncMappingsFromForm($form_state
->getValues());
// Notify the user if no actual synchronization event is active for a field.
$this
->checkEmptyEvents($processed_mappings);
}