You are here

function ldap_servers_admin_form_validate in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_servers/ldap_servers.admin.inc \ldap_servers_admin_form_validate()
  2. 7 ldap_servers/ldap_servers.admin.inc \ldap_servers_admin_form_validate()

Validate hook for the LDAP server form.

File

ldap_servers/ldap_servers.admin.inc, line 62
Defines functions for administrative interface for servers

Code

function ldap_servers_admin_form_validate($form, &$form_state) {
  $op = drupal_strtolower($form_state['clicked_button']['#value']);
  ldap_servers_module_load_include('php', 'ldap_servers', 'LdapServerAdmin.class');
  $server = new LdapServerAdmin($form_state['values']['sid']);
  $errors = $server
    ->drupalFormValidate($op, $form_state['values']);
  foreach ($errors as $error_name => $error_text) {
    form_set_error($error_name, t($error_text));
  }
  $warnings = $server
    ->drupalFormWarnings($op, $form_state['values'], (bool) (count($errors) > 0));
  foreach ($warnings as $warning_name => $warning_text) {
    drupal_set_message($warning_text, 'warning');
  }
  $form_state['ldap_warnings'] = (bool) (count($warnings) > 0);
}