function search_autocomplete_treelist_form in Search Autocomplete 7.4
Same name and namespace in other branches
- 6.4 search_autocomplete.form.treelist.inc \search_autocomplete_treelist_form()
- 6.2 search_autocomplete.form.treelist.inc \search_autocomplete_treelist_form()
- 7.2 search_autocomplete.form.treelist.inc \search_autocomplete_treelist_form()
- 7.3 search_autocomplete.form.treelist.inc \search_autocomplete_treelist_form()
Menu Callback: create the form to list the search forms.
Return value
array the form
1 string reference to 'search_autocomplete_treelist_form'
- search_autocomplete_menu in ./
search_autocomplete.admin.inc - Implements hook_menu().
File
- ./
search_autocomplete.form.treelist.inc, line 19 - Search Autocomplete Display the list of form to autocomplete and theme it as a draggable table.
Code
function search_autocomplete_treelist_form($form, &$form_state) {
// Base URL for this module configurations.
$base = "admin/config/search/search_autocomplete";
// Get all forms ordered as a tree.
$data = _search_autocomplete_get_items();
$form['my_items'] = array();
$form['my_items']['#tree'] = TRUE;
// For each items to render in the form.
foreach ($data as $values) {
$fid = $values->fid;
$title = $values->title;
$weight = $values->weight;
$enabled = $values->enabled;
$parent_fid = $values->parent_fid;
$translite = variable_get('sa_translite', TRUE);
$admin_helper = variable_get('sa_admin_helper', TRUE);
$form['my_items'][$fid] = array(
'title' => array(
'#type' => 'item',
'#title' => check_plain($title),
),
// Defines if the autocompletion is enabled for this item.
'enabled' => array(
'#type' => 'checkbox',
'#default_value' => $enabled,
),
'operations' => array(
'configure' => array(
'#type' => 'item',
'#title' => filter_xss(l(t('configure'), "{$base}/{$fid}/configure")),
),
'delete' => array(
'#type' => 'item',
'#title' => filter_xss(l(t('delete'), "{$base}/{$parent_fid}/delete/{$fid}")),
),
),
// Weight of the item in hierarchy.
'weight' => array(
'#type' => 'weight',
'#delta' => count($data),
'#default_value' => $weight,
),
// The individual id if the item.
'fid' => array(
'#type' => 'hidden',
'#value' => $fid,
),
// Id of the parent item in hierarchy.
'parent_fid' => array(
'#type' => 'textfield',
'#default_value' => $parent_fid,
),
// Depth of the item.
'#depth' => $values->depth,
);
}
// Transliteration option settings.
$title = t('Translite special characters.') . ' (' . t('Requires <a href="https://drupal.org/project/transliteration">Transliteration</a> module.') . ' : ';
$title .= module_exists('transliteration') ? '<b>' . t('Installed') . '</b>' : '<b>' . t('Not installed') . '</b>';
$title .= ')';
$form['translite'] = array(
'#type' => 'checkbox',
'#title' => $title,
'#description' => t('If enabled, the user will be suggested with all special characters suggestions when using standard characters. In other word, when entering "foo", suggestions may contain also "fóôbar", "foõbar", ...'),
'#disabled' => module_exists('transliteration') ? FALSE : TRUE,
'#default_value' => $translite,
);
// Use admin helper tool option settings.
$title = t('Use autocompletion helper tool for Search Autocomplete administrators.');
$form['admin_helper'] = array(
'#type' => 'checkbox',
'#title' => $title,
'#description' => t('If enabled, user with "administer Search Autocomplete" permission will be able to use admin helper tool on input fields (recommended).'),
'#default_value' => $admin_helper,
);
// Submit buton.
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}