4

Background
I am using the modules: geocoder geofield addressfield geophp ip_geoloc libraries to create a store locator view. The user can search the available stores using an exposed GeoField proximity filter.

Question
How can I restyle the GeoField's proximity filter controls? I would like to change the edit box for distance to a select with fixed values, and hide the distance units select defaulting it to miles. Screen shot showing standard proximity filter controls

2 Answers 2

4

I had a similar issue with editing the exposed form. Form alter is not the right way to go though. You'll need to use element info alter. Take a look at this custom module I threw together for editing the geofield proximity search. You can see what I did, and add/modify functionalities for your needs (although I think i did exactly what you wanted).

1
  • 1
    I used cojomojo's module as a starting point, it helped me a lot.
    – Jay Haase
    Jun 30, 2014 at 16:01
2

Something like

function yourmodule_form_alter(&$form, &$form_state, $form_id) {
   if (($form_id == 'views_exposed_form') &&  ($form['#id'] == 'views-exposed-form-your-view')) {
    $form['proximity']['default_radius']['#type'] = 'select';
    $form['proximity']['default_radius']['#options'] = array(10, 20, 30);
    $form['proximity']['radius_unit']['#type'] = 'item';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.