Inspired by the excellent LDAP Integration Module. I'm creating a module that will return user demographics from a LDAP query. There is just something that I'm not getting about the form submit process.
I have my form with 1 text field and 1 submit button:
function ldap_dir_menu() {
$items = array();
$items[] = array(
'path' => 'directory',
'title' => t(variable_get('form_title','LDAP Directory')),
'callback' => 'drupal_get_form',
'callback arguments' => array('ldap_dir_search_form'),
'access' => user_access('administer ldap_dir'),
'type' => MENU_CALLBACK,
);
return $items;
}
function ldap_dir_search_form(){
$form['dir-search']['keyword'] = array(
'#type' => 'textfield',
'#title' => t('Search directory'),
'#description' => t('Search the directory'),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
);
$form['dir-search']['submit'] = array(
'#type' => 'submit',
'#value' => t('Search')
);
return $form ;
}
I have my "_submit" function:
function ldap_dir_search_form_submit($form_id, $form_values) {
// Run the LDAP query to get the matching entries from the form text field
$output = "bunch of logic to get LDAP entries"...
}