function search_api_saved_searches_search_edit_form in Search API Saved Searches 7
Form builder for editing a saved search.
Parameters
SearchApiSavedSearch $search: The search to edit.
See also
search_api_saved_searches_search_edit_form_submit()
1 string reference to 'search_api_saved_searches_search_edit_form'
- search_api_saved_searches_menu in ./
search_api_saved_searches.module - Implements hook_menu().
File
- ./
search_api_saved_searches.pages.inc, line 176 - User UI functions and form callbacks for saved searches.
Code
function search_api_saved_searches_search_edit_form(array $form, array &$form_state, SearchApiSavedSearch $search) {
$form_state['search'] = $search;
$settings = $search
->settings();
if ($search->uid) {
$form_state['destination']['path'] = 'user/' . $search->uid . '/saved-searches';
}
elseif (!empty($search->options['page'])) {
$form_state['destination'] = array(
$search->options['page']['path'],
$search->options['page'],
);
}
$form['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#description' => t('Disable to stop receiving notifications from this saved search.'),
'#default_value' => $search->enabled,
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('The name that will be displayed for this saved search.'),
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => $search->name,
);
if (!empty($settings->options['allow_keys_change'])) {
$keywords = $search->query['keys'];
if (is_array($keywords)) {
$keywords = search_api_saved_searches_unparse_keys($keywords);
}
$form['keys'] = array(
'#type' => 'textfield',
'#title' => t('Keywords'),
'#description' => t('The keywords to use for this search.'),
'#default_value' => $keywords,
);
}
if ($settings->options['user_select_interval'] && count($settings->options['interval_options']) > 1) {
$form['notify_interval'] = array(
'#type' => 'select',
'#title' => t('Notification interval'),
'#options' => $settings
->getTranslatedOption('interval_options'),
'#required' => TRUE,
'#default_value' => $search->notify_interval,
);
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save changes'),
);
if (!empty($form_state['destination'])) {
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => $form_state['destination']['path'],
'#options' => $form_state['destination'],
);
}
return $form;
}