This has been bugging me all day and i'm still none the wiser and would really appreciate help.

I want to expose date (node) field on my view so that users can select a year and see blog articles.

I've managed to expose the filter in a dropdown box but need to create them as checkboxes.

So i've used hook_form_alter and tried to change the $form['date_filter'] to a checkbox array like so:

$form['date_filter'] = array(
'#type' => 'checkboxes',
'#options' => array(
'2013' => '2013',
'2014' => '2014',
'2015' => '2015',
'2016' => '2016',
'#title' => t('Year filter'),

While this does change the dropdown into a list of checkboxes the checkboxes no longer work when I select one and click apply.

So I inspected the select tag and the name attribute was date_filter[value][year] where as my checkboxes name attributes are: date_filter[2013], date_filter[2014], and so on.

I would like to know if this is what is causing the form to no longer filter my articles and if it is how to fix it? IF not what else can I do?

P.S. I've installed Better exposed filters and this doesn't allow me to change date to checkboxes, only datepicker.

  • try using the Better Exposed Filters module
    – 2pha
    Commented Jan 24, 2015 at 2:41
  • I stated in the post that BEF doesmt provide this Commented Jan 24, 2015 at 13:18
  • Ok, I was half asleep and didn't read it thoroughly. Anyway, Yes the name of the filter will probably be what is causing the issue, There is an option to change the name of the filter, called 'filter identifier' which is visible when you click 'more' at the bottom of the exposed filter settings. Maybe this will help
    – 2pha
    Commented Jan 24, 2015 at 13:31


Your Answer

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

Browse other questions tagged or ask your own question.