You are here

function ldap_api_list_servers_form in Lightweight Directory Access Protocol (LDAP) 6

Server Listing/Weight implimentation of hook_form(). Creating the actual form itself happens here.

See also

http://api.drupal.org/api/file/developer/topics/forms_api.html/6

http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6

1 string reference to 'ldap_api_list_servers_form'
ldap_api_list_servers in ./ldap_server.admin.inc
Page callback created in the implementation of hook_menu.

File

./ldap_server.admin.inc, line 27

Code

function ldap_api_list_servers_form($form_state) {
  ctools_include('ajax');

  // Module  include the dependence it needs for ajax.
  ctools_include('modal');
  ctools_modal_add_js();
  $form = array();
  $form['list'] = array();
  $form['list']['#tree'] = TRUE;
  $items = _ldap_api_get_servers();
  foreach ($items as $values) {
    $form['list'][$values->sid]['sid'] = array(
      '#type' => 'hidden',
      '#value' => $values->sid,
    );
    $form['list'][$values->sid]['name'] = array(
      '#value' => $values->name,
    );

    //    $form['list'][$values->sid]['active'] = array('#value' => $values->active);
    $form['list'][$values->sid]['edit'] = array(
      '#value' => l(t('edit'), 'admin/settings/ldap/servers/' . $values->sid . '/edit'),
    );
    $form['list'][$values->sid]['active'] = $values->active ? array(
      '#value' => ctools_modal_text_button(t('deactivate'), 'admin/settings/ldap/servers/' . $values->sid . '/deactivate', t('Deactivate this server.')),
    ) : array(
      '#value' => ctools_modal_text_button(t('activate'), 'admin/settings/ldap/servers/' . $values->sid . '/activate', t('Activate this server.')),
    );
    $form['list'][$values->sid]['delete'] = array(
      '#value' => ctools_modal_text_button(t('delete'), 'admin/settings/ldap/servers/' . $values->sid . '/delete', t('Delete this server/')),
    );
    $form['list'][$values->sid]['weight'] = array(
      '#type' => 'weight',
      '#default_value' => $values->weight,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['add'] = array(
    '#type' => 'submit',
    '#value' => t('Add Server'),
  );
  return $form;
}