2

I have an issue that needs the help of everyone. I created the page in view to filter the node. I created a filter Date created in "view exposed filter" for filter by Date created.

I configured for the Filter granularity is check month, that filter will display 2 dropbox to me to choose, i.e. month and year dropbox. But I want to display only months option and defaults year is the current year. Do not know if anyone can help me handle the matter.

Thank you very much

enter image description hereenter image description here

1

Using CSS and jQuery you can achieve your requirement.

Step 1: Using jQuery, on change() event of month select list assign current year to year select list.

$(".date-month").change(function(){
    //write code to set current year to year select list.
});

Step 2: Now using CSS, hide year select list.

.date-year {
    display: none;
}

Note: You can also achieve the same functionality using Drupal custom hooks.

  • 1
    How i can use form_views_exposed_form_alter? – Lê Quang Tú Nov 14 '15 at 2:56
  • Sorry, I have not tried form_views_exposed_form_alter hook. – Nikhil Banait Nov 14 '15 at 4:43
  • Hi. You can look Month and Year dropbox. It have label is '-Month' and '-Year'. I want change it to '-Month-'. How i can change it? – Lê Quang Tú Nov 15 '15 at 15:35
  • To change the label, you can also do it using jQuery. Please always make sure to ask new question, when you have any new thing to discuss. – Nikhil Banait Nov 15 '15 at 16:05
  • Oh. When i set value for year by jquery when i serch not select month it will display validate required month. – Lê Quang Tú Nov 16 '15 at 2:12

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.