You are here

function search_api_admin_server_edit in Search API 7

Form constructor for editing a server's settings.

Parameters

SearchApiServer $server: The server to edit.

See also

search_api_admin_server_edit_validate()

search_api_admin_server_edit_submit()

1 string reference to 'search_api_admin_server_edit'
search_api_menu in ./search_api.module
Implements hook_menu().

File

./search_api.admin.inc, line 594
Administration page callbacks for the Search API module.

Code

function search_api_admin_server_edit(array $form, array &$form_state, SearchApiServer $server) {
  $form_state['server'] = $server;
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Server name'),
    '#description' => t('Enter the displayed name for the  server.'),
    '#maxlength' => 50,
    '#default_value' => $server->name,
    '#required' => TRUE,
  );
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled'),
    '#default_value' => $server->enabled,
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Server description'),
    '#description' => t('Enter a description for the new server.'),
    '#default_value' => $server->description,
  );
  $class = search_api_get_service_info($server->class);
  $service_options = array();
  $service_options = $server
    ->configurationForm($service_options, $form_state);
  if ($service_options) {
    $form['options']['form'] = $service_options;
  }
  $form['options']['#type'] = 'fieldset';
  $form['options']['#tree'] = TRUE;
  $form['options']['#collapsible'] = TRUE;
  $form['options']['#title'] = $class['name'];
  $form['options']['#description'] = $class['description'];
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  $form['actions']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#submit' => array(
      'search_api_admin_form_delete_submit',
    ),
    '#limit_validation_errors' => array(),
  );
  return $form;
}