function search_api_location_input_geocoder_form in Search API Location 7.2
Provides a configuration form for this location input plugin.
Parameters
array $form_state: The form state data.
Return value
array A form array for configuring this location input plugin.
1 string reference to 'search_api_location_input_geocoder_form'
- geocoder.inc in plugins/
location_input/ geocoder.inc
File
- plugins/
location_input/ geocoder.inc, line 53
Code
function search_api_location_input_geocoder_form(array &$form_state, array $options) {
$options += array(
'geocoder_handler' => NULL,
'geocoder_handler_options' => array(),
);
$handler_id = NULL;
$processor = NULL;
if (!empty($form_state['values'])) {
$handler_id = _search_api_location_array_get_nested_value($form_state['values'], 'geocoder_handler');
}
$handler_id = $handler_id ? $handler_id : $options['geocoder_handler'];
if ($handler_id) {
$processor = geocoder_get_handler($handler_id);
}
$handlers = array();
foreach (geocoder_handler_info() as $id => $handler) {
$handlers[$id] = $handler['title'];
}
$form['geocoder_handler'] = array(
'#type' => 'select',
'#title' => t('Handler'),
'#description' => t('Select the input format for Geocoder.'),
'#options' => $handlers,
'#default_value' => $options['geocoder_handler'],
'#ajax' => array(
'callback' => 'search_api_location_input_geocoder_form_ajax',
'wrapper' => 'search-api-location-handler-options',
),
);
if ($processor) {
$form['geocoder_handler_options'] = array(
'#type' => 'fieldset',
'#title' => t('Handler options'),
'#tree' => TRUE,
'#prefix' => '<div id="search-api-location-handler-options">',
'#suffix' => '</div>',
);
if (!empty($processor['description'])) {
$form['geocoder_handler_options']['#description'] = $processor['description'];
}
if (!empty($processor['settings_callback'])) {
$handler_options = $processor['name'] == $options['geocoder_handler'] ? $options['geocoder_handler_options'] : array();
$options_form = $processor['settings_callback']($handler_options);
if ($options_form) {
$form['geocoder_handler_options'] += $options_form;
}
}
}
else {
$form['geocoder_handler_options']['#markup'] = '<div id="search-api-location-handler-options"></div>';
}
return $form;
}