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
- Content:Published = Yes
- Content: Type = My content type
- Content: Genre field (exposed) with no default value set
- 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']
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff-2309015-4-7.txt | 1.2 KB | Temoor |
#7 | date-exposed-filter-form_state-empty-input-2309015-7.patch | 1.7 KB | Temoor |
Comments
Comment #1
msankhala CreditAttribution: msankhala commentedThe 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.
Comment #2
msankhala CreditAttribution: msankhala commentedComment #4
msankhala CreditAttribution: msankhala commentedAttaching new patch which follow patch creation standard.
Comment #5
msankhala CreditAttribution: msankhala commentedComment #7
Temoor CreditAttribution: Temoor commentedReproduced in current dev version too.
Updated patch as long as previous one causes fatal error.
Comment #8
podarok#7 commited
Thanks!
Comment #10
m1r1k CreditAttribution: m1r1k commentedComment #12
stefan.r CreditAttribution: stefan.r commentedJust for the record, this commit introduced a new bug: #1437892: Undefined index notices in date_popup.module and default values disappear
Comment #13
Michelle@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.
Comment #14
Ether CreditAttribution: Ether commentedPlease rollback the patch as it introduces #2420323: Exposed date filter shouldn't automatically set a default date if none requested.