public function geofieldProximityGeocoderWithHTML5::options_form in IP Geolocation Views & Maps 7
Overrides geofieldProximityGeocoder::options_form
File
- views/
proximity_plugins/ geofieldProximityGeocoderWithHTML5.inc, line 35 - Contains geofieldProximityGeocoderWithHTML5.
Class
- geofieldProximityGeocoderWithHTML5
- @file Contains geofieldProximityGeocoderWithHTML5.
Code
public function options_form(&$form, &$form_state, $views_plugin) {
parent::options_form($form, $form_state, $views_plugin);
// Make sure that the Geocoder-provided form elements are visible.
$form['geofield_proximity_geocoder_engine']['#dependency']['edit-options-source'][] = 'geocoder_with_HTML5';
$form['geofield_proximity_geocoder']['#dependency']['edit-options-source'][] = 'geocoder_with_HTML5';
// This description is shown on the Geofield FIELD (not FILTER) form.
$form['geofield_proximity_geocoder']['#description'] = t("Enter a partial address or leave blank to use the visitor's current position as the origin.");
/* Show/hide works on whole fields only, not on description only...
$form['geofield_proximity_geocoder']['#description']['#states'] = array(
'visible' => array(
'select[name="options[source]"]' => array('value' => 'geocoder_with_HTML5'),
),
);*/
$form['geofield_proximity_geocoder_engine']['#states'] = array(
'invisible' => array(
':input[name="options[geofield_proximity_geocoder]"]' => array(
'value' => '',
),
),
);
if (empty($views_plugin->view->display_handler->handlers['filter'])) {
return;
}
$filters = $views_plugin->view->display_handler->handlers['filter'];
$exposed_geofields = array();
foreach ($filters as $name => $filter) {
if ($filter->definition['handler'] == 'geofield_handler_filter' && !empty($filter->options['exposed'])) {
$exposed_geofields[$name] = $filter
->ui_name();
}
}
if (!empty($exposed_geofields)) {
$options = array(
'' => '-- ' . t("no don't do that") . ' --',
) + $exposed_geofields;
$form['geofield_proximity_with_HTML5_share_exposed'] = array(
'#type' => 'select',
'#title' => t('Inherit filter values from the exposed filter belonging to the field below'),
'#options' => $options,
'#default_value' => $views_plugin->options['geofield_proximity_with_HTML5_share_exposed'],
'#states' => array(
'visible' => array(
':input[name="options[expose_button][checkbox][checkbox]"]' => array(
'checked' => FALSE,
),
'select[name="options[source]"]' => array(
'value' => 'geocoder_with_HTML5',
),
),
),
);
// Suppress the "Proximity Search" fields (distance, unit, origin) when
// an alternative Geofield filter is selected above.
$form['value']['#states'] = array(
'visible' => array(
':input[name="options[geofield_proximity_with_HTML5_share_exposed]"]' => array(
'value' => '',
),
),
);
}
}