The title basically says it.
When a date field is set as required, when creating a node, the date field is populated with the current date.

Additional info requested is:
1) Date
2) jquery popup
3) Not sure about the timezone.
4) Not using multiple
5) Obviously, yes, it is required.

This is a usability issue since it encourages entering incorrect information. If it were empty, validation would catch it and alert the user, where as this way, if the user doesn't spot it, the incorrect date is entered.

Comments

Gidgidonihah’s picture

Well I just started to play around with this. First I wanted to figure out how to not populate the required fields with todays date.
I found that in date_api_elements.php starting on line 171 there is this code:

  elseif ($element['#required']) {
    $date = date_now($element['#date_timezone']);
  }

If I comment out that second line, line 172, the date elements aren't populated with the current date, but that creates other problems.
With that line commented, when a node is submitted without filling out the required fields, those fields are not hilighted in red, nor are they named as required in the error messages. In addition, a php warning is returned.
Here is the message:

* field is required.
* field is required.
* field is required.
* warning: preg_match() expects parameter 2 to be string, array given in /storage/html/drupal/sites/all/modules/date/date_api.module on line 795.
* warning: preg_match() expects parameter 2 to be string, array given in /storage/html/drupal/sites/all/modules/date/date_api.module on line 795.
* warning: preg_match() expects parameter 2 to be string, array given in /storage/html/drupal/sites/all/modules/date/date_api.module on line 795.
* warning: preg_match() expects parameter 2 to be string, array given in /storage/html/drupal/sites/all/modules/date/date_api.module on line 795.
* warning: preg_match() expects parameter 2 to be string, array given in /storage/html/drupal/sites/all/modules/date/date_api.module on line 795.

This is for a date field with Month, Day, Year select lists.

karens’s picture

Status: Active » Fixed

You have the option in the field settings screen to set the default value - it can be blank, or 'now' or something like '+90 days'. And you can set a default for the To date to be the same as the From date or any of those options. There should be no need to make any changes to the code to get this to work.

Gidgidonihah’s picture

Category: bug » support
Status: Fixed » Active

Thanks Karen, I know it's an option to default to blank. One of the reasons I upgraded.

I don't want to seem ungrateful or like I'm trying to be offensive (happens too often around here), but It seems you quickly wrote this off as somebody being stupid and not doing the obvious things. And maybe it is, but not the one you thought :P

It states it in the title of the thread, though I probably should have been more clear about it, that:

The fields are set to default blank, but they aren't doing that.

I can't have bad data being entered automatically which is why I'm playing around with the code until someone else can help me realize the giant magic step that I forgot to take that makes all my problems go away :)

To verify, I created a new content type with only one field, a select date field with all other options set to default, including defaulting to blank. When I try to create new content of that type, all fields are still filled out with the current date.

And yes, I did upgrade from date-5.x-1.8.
Yes I deleted the date folder before extracting the new date module.
Yes I ran the update script.

Gidgidonihah’s picture

Version: 5.x-2.x-dev » 5.x-2.0-rc
Category: support » bug
Status: Active » Fixed

First of all, I just noticed that I had the wrong version. And I accidentally changed it from a bug report. I fail all over. Let's change that now.

I upgraded to 5.x-2.0-dev and the whole problem was solved. However the broken validation as stated above is persistant, so let's break that out into another issue. This one is fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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