I have build an proximity search and all works fine when i search for cities. But sometimes, when i search for an zipcode, the search breaks and will show no results. When i add the country to circe[location] then it will work.
As example:
circle[location]=74072
dont work

circle[location]=74072+de
work

circle[location]=heilbronn
work

Is there any way to add an default country?

Comments

Helrunar’s picture

Priority: Normal » Minor
Status: Active » Fixed

Here is a small solution with an custom module. First we use hook_form_alter to set a function to validate

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form ['#id'] === "my-exposed-form-id") {
    $form['#validate'][] = 'MYMODULE_form_validator';
  }
}

then we use hook_form_validator to inject the default country

function MYMODULE_form_validator(&$form, &$form_state) {
  if (isset($form_state['values']['circle']['location']) && !(strstr($form_state['values']['circle']['location'], 'Deutschland'))) {
    $form_state['values']['circle']['location'] = $form_state['values']['circle']['location'] . ' Deutschland';
  }
}

I will close this as fixed, but i think it will be a good solution to provide settings for countries as options to set in the module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.