Download & Extend

Default value set to 1000 years back when #access is FALSE

Project:Date
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I have a date field that in a hook_form_alter set '#access' = FALSE to it. the default value - "now" is set to 16.03.1009 instead of 16.03.2009.

Comments

#1

Here is the field definition.
Am i doing something wrong ?

AttachmentSizeStatusTest resultOperations
test_field_date_access_false.txt2.53 KBIgnored: Check issue status.NoneNone

#2

I have a similar problem.

I created a year-only, Select List date field. The default value is set to relative and the Years back and forward is set to -100:+0. It gives me a range of years from 979 to 2009.

Changing the years back doesn't affect the lower limit of 979, but changing the years forward does change the upper limit of 2009.

For example:
-30:+0 gives the range 979 to 2009.
-100:+3 gives the range 979 to 2012.

I've tried clearing the cache and running cron (as sometimes errors are in changes not being applied due to the cache), but it doesn't help. I can try tracing the error in the code, but I'm not familiar with the code in this module, so I'll be slow.

Any help would be awesome.

#3

don't know if it helps but this is what i could find out so far: in date_api_elements.inc in function date_text_validate the $element['#value'] is set correctly (ie. 2009-03-18 10:54:15). Unfortunately in the same function the $form_state['values']['field_test_data'][0]['value'] is set to 1000 years back - 1009-03-18 10:54:15.
I'll try to dig further but I'm blocked here i think...

Any help is solving this is greatly appreciated.

#4

I tried it with the latest Dev version from 2009-Mar-19 and this is even worse. I get the following errors:

warning: Invalid argument supplied for foreach() in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 429.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 473.
warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 476.
warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 477.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 479.
warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 480.
warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 481.
warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 482.
warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 483.
warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 491.
warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 492.
warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 493.
warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/my_site/sites/all/modules/date/date/date_elements.inc on line 496.

#5

Title:Default value set to 1000 years back» Default value set to 1000 years back when #access is FALSE

Changed the title to better reflect the problem.

#6

Subscribe.

#7

Priority:normal» critical

Bumping .. anyone have a solution?

#8

I don't think so...

I ended up working around the problem by doing something else entirely. I never traced the problem to its source, so I don't actually know what's causing the problem.

#9

Subscribing.

I'm having a similar issue with the Multistep module. Whenever there's a date field (I haven't yet figured out how to make Multistep work with those properly) after the first rebuild the year becomes blank and instead the drop-down shows from 9 to 2009, with an empty value at the top. If I unset $form_state['rebuild'] it renders normally (although the value disappears once you submit a different step, but that's a separate issue).

#10

See http://drupal.org/node/408770#comment-1764744 (#408770: #access of date_combo fields prevents validation). The approach for solving that issue also solved this for me. I haven't had a problem with that code yet, but use it with caution.

#11

Status:active» fixed

According to #10, #408770: #access of date_combo fields prevents validation potentially fixes the issue.
So, I am going to mark this as fixed.

If you still have the issue, please re-open and provide details about how to reproduce the issue.

Thanks

#12

Status:fixed» closed (fixed)

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

nobody click here