function data_search_admin_form in Data 8
Same name and namespace in other branches
- 6 data_search/data_search.admin.inc \data_search_admin_form()
- 7 data_search/data_search.admin.inc \data_search_admin_form()
Views handler configuration form.
1 string reference to 'data_search_admin_form'
- data_search_menu in data_search/
data_search.module - Implements hook_menu().
File
- data_search/
data_search.admin.inc, line 6
Code
function data_search_admin_form($form, &$form_state, $table) {
$messenger = \Drupal::messenger();
drupal_set_title($table
->get('title'));
$schema = $table
->get('table_schema');
$meta = $table
->get('meta');
$form = array();
if (count($schema['primary key']) != 1) {
$messenger
->addError(t('Only tables with a single-field primary key can be indexed.'), 'error');
return $form;
}
// Keep table.
$form['#table'] = $table;
// Existing fields.
$form['fields'] = array(
'#tree' => TRUE,
);
if (isset($schema['fields'])) {
$enabled_fields = data_search_get_fields($table);
foreach ($schema['fields'] as $field_name => $field) {
$form['fields'][$field_name] = array();
$form['fields'][$field_name]['name'] = array(
'#value' => $field_name,
);
$form['fields'][$field_name]['search'] = array(
'#type' => 'checkbox',
'#default_value' => in_array($field_name, $enabled_fields),
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}