Closed (fixed)
Project:
Date
Version:
5.x-1.8
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Dec 2007 at 11:25 UTC
Updated:
9 Apr 2008 at 01:17 UTC
Hi!
I would really like to have the date field as blank when required. The problem on my site is that people are too sloppy when signing up and just except the default, hence many people are born in 2007.
So, I would really want to push the user to do an active choice, have the default as blank and the field as required.
In Date 2.0:
The Date module now has lots of new ways to define default values -- you can set a the default to 'blank'
Is there a way to hack the 1.8 to get this feature? Right now I decided to not even use the 'Date' field and have a normal integer field, just to get the blank (many drawbacks).
All suggestions are wellcome! Thanks a lot!
Seth
Comments
Comment #1
karens commentedThere's always a way to hack things if you want to spend time figuring out how to get it to work and doing all the debugging, but this will be in 5.2 which is almost ready, so I won't be adding it to 5.1.8 or spending any time to figure out how it could be done.
Comment #2
beautifulmindYou could use php function 'strtotime()' to store data as integer and while retrieving from db use format_date() function of drupal.
Hope this could be helpful.
Comment #3
seth97 commentedOk, I'll wait for the 5.2.
Thanks!
Seth
Comment #4
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
threexk commentedI was less patient than poster and wrote a module to do it. It blanks all date field default values without discrimination.
date_blankfields.module:
date_blankfields.info:
I'm a PHP novice, so if there is a more condensed way to code it, I'd be interested to know. (Some curly braces could've been omitted for one-line conditional bodies.)
Comment #6
wongle commentedI just noticed that this will also blank date fields that have data in them when going to edit a node...
Comment #7
threexk commentedThanks for pointing that out. A little hack to check whether we're on an add-node page fixes the problem for me.
date_blankfields.module:
I'm still using this little module because 5.x-2.0-rc won't blank a required date field. See #234073: Setting a date field as required shows today's date even if default value is "blank".