function views_plugin_style_json::options_form in Search Autocomplete 6.4
Provide a form for setting options.
_state
Parameters
$form:
File
- json_autocomplete/
plugin/ views_plugin_style_json.inc, line 34 - Implementation of views_plugin_style for json_autocomplete.
Class
- views_plugin_style_json
- Implementation of views_plugin_style
Code
function options_form(&$form, &$form_state) {
// Get all views fields.
$all_view_fields = $this->display->handler
->get_field_labels();
// Build the value option.
$group_fields = $all_view_fields;
array_unshift($group_fields, "- no grouping -");
$form['group_by'] = array(
'#title' => t('Group fields by'),
'#type' => 'select',
'#description' => (empty($all_view_fields) ? '<b>' . t('Warning') . ': </b> ' . t('Requires at least one field in the view.') . '<br/>' : '') . t("You may want to group fields together."),
'#default_value' => $this->options['group_by'],
'#disabled' => empty($all_view_fields),
'#required' => TRUE,
'#options' => $group_fields,
);
$form['input_value'] = array(
'#title' => t('Input Value'),
'#type' => 'select',
'#description' => (empty($all_view_fields) ? '<b>' . t('Warning') . ': </b> ' . t('Requires at least one field in the view.') . '<br/>' : '') . t('Select the autocompletion input value. If the autocompletion settings are set to auto-submit, this value will be submitted as the suggestion is selected.'),
'#default_value' => $this->options['input_value'],
'#disabled' => empty($all_view_fields),
'#required' => TRUE,
'#options' => $all_view_fields,
);
// Build the link option.
$form['input_link'] = array(
'#title' => t('Input Link'),
'#type' => 'select',
'#description' => (empty($all_view_fields) ? '<b>' . t('Warning') . ': </b> ' . t('Requires at least one field in the view.') . '<br/>' : '') . t('Select the autocompletion input link. If the autocompletion settings are set to auto-redirect, this link is where the user will be redirected as the suggestion is selected.'),
'#default_value' => $this->options['input_link'],
'#disabled' => empty($all_view_fields),
'#required' => TRUE,
'#options' => $all_view_fields,
);
// Build the link option.
$form['output_fields'] = array(
'#title' => t('Output Fields'),
'#type' => 'select',
'#description' => (empty($all_view_fields) ? '<b>' . t('Warning') . ': </b> ' . t('Requires at least one field in the view.') . '<br/>' : '') . t("Select the autocompletion output values. Thoses fields are the one that will show in the autocompletion popup suggestion list. This may be, the username and picture for instance, or the node title and it's author."),
'#default_value' => $this->options['output_fields'],
'#disabled' => empty($all_view_fields),
'#required' => TRUE,
'#multiple' => TRUE,
'#options' => $all_view_fields,
);
}