Changing the way an exposed numeric (float) filter is displaying

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
moonshield's picture

Hello, I have a view filter form with a numeric field let's say price with a between operator I want to replace the regular min/max input fields with a list of checkboxes where I define a list of ranges.

Could someone please tell me where Can i start looking to do so?
any documentation examples ara welcome.
I am digging into views handlers can this be leading to a solution or it's a dead end?

Thanks a lot

Comments

Custom handler is the way to go

tinker's picture

Yes creating a custom filter handler would allow you to do this. The documentation is sparse. Try looking at http://views.doc.logrus.com/ for more info. You would start by creating a new handler file. The override what you need to. I forget which form is displayed to the end user, maybe exposed_form?

<?php
class my_views_handler_filter_numeric extends views_handler_filter_numeric {
 
// override form
 
function exposed_form(&$form, &$form_state) {
   
// get the original form
   
parent::exposed_form(&$form, &$form_state);
   
// make changes to the form elements here

 
}
}
?>

Best way to figure it out is to look at the other handlers in the view module and see how they all extend another one and override certain settings. You will also need a custom module that exposes this handler to views. See http://treehouseagency.com/blog/neil-hastings/2010/01/19/views-handler-e...

Is this one off?

codamoda's picture

Thinking back on my earlier post: if you want to implement this for all numeric fields then the handler is the way to go. If you want to change the form for a specific search function then you could use a hook_form_alter on the form to change the display.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: