Views date field exposed filter default value not being added in $form_state['input'] when initially views loads. I encounter this problem when i was creating a view with the date field filter.
I have a content type which have a release date field of date type and genre field of term reference type. I created a view with the Four filter

  1. Content:Published = Yes
  2. Content: Type = My content type
  3. Content: Genre field (exposed) with no default value set
  4. Content: Release date field (exposed) with no default value set

Release date field's granularity was set 'Year' in release date field configuration. I want to do alter the release date field value in exposed form in hook_form_alter().

Problem:
When initially views loads the value of release date field filter is not available in $form_state['input'] in hook_form_alter. while genre field filter value is available in $form_state['input']

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

msankhala’s picture

The reason was that $form_state variable was not being passed by reference to date_parts_form function in date_views_filter_handler_simple handler. Attaching patch.

msankhala’s picture

Status: Active » Needs review

Status: Needs review » Needs work
msankhala’s picture

Attaching new patch which follow patch creation standard.

msankhala’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Temoor’s picture

Version: 7.x-2.7 » 7.x-2.x-dev
Status: Needs work » Needs review
FileSize
1.7 KB
1.2 KB

Reproduced in current dev version too.
Updated patch as long as previous one causes fatal error.

podarok’s picture

Status: Needs review » Fixed

#7 commited
Thanks!

  • podarok committed c2e081f on 7.x-2.x authored by Temoor
    Issue #2309015 by msankhala, Temoor: Fixed views date field exposed...
m1r1k’s picture

Issue tags: +#ams2014contest

Status: Fixed » Closed (fixed)

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

stefan.r’s picture

Issue tags: -
Michelle’s picture

@Temoor - You are setting the default to the current date in your patch, which is causing #2420323: Exposed date filter shouldn't automatically set a default date if none requested . I am trying to figure out another way of doing it but it would help to have your input since you are the patch author.

Ether’s picture

Please rollback the patch as it introduces #2420323: Exposed date filter shouldn't automatically set a default date if none requested.