1

I use Views module and I've got search to specify results.

enter image description here

In the search I've got filter for field cena. I set operator between so user can fill in min cena and max cena.

How can I change the appearance of that search? For and foremost I'd like to remove "And" between inputs for min cena and max cena. If it's possible I also want to create placeholders in inputs for min cena and max cena.

  • What do you mean by placeholders? – Pontus Nilsson Aug 4 '13 at 10:07
1

To remove the And title you need to implement hook_form_alter(). It would look something like this.

/**
 * Implements hook_form_FORM_ID_alter().
 */ 
function mymodule_form_views_exposed_form_alter(&$form, &$form_state){
  if ($form['#id'] == 'views-exposed-form-search-page') {
    unset($form['field_price1_value']['max']['#title']);    
  }  
}

You will also need to find out the $form['#id'] so that your code doesn't attempt to change all exposed forms generated by views. Install the Devel module and run.

/**
 * Implements hook_form_FORM_ID_alter().
 */ 
function mymodule_form_views_exposed_form_alter(&$form, &$form_state) {
  dsm($form['#id']);
}

The devel module will now set a message with each views exposed form and it's #id. Copy that and replace views-exposed-form-search-page in the first code example. After that you can add a dsm($form); to find out what your field name is called in the array (to replace field_price1_value).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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