The fields should default to the current date and time.

CommentFileSizeAuthor
#1 date_popup_authored.868592.patch857 bytestimmillwood
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timmillwood’s picture

Status: Active » Needs review
FileSize
857 bytes

Here's a patch for this.

Mark Trapp’s picture

Status: Needs review » Closed (works as designed)

Core (and by extension, Date Popup Authored) doesn't set the default value when you load up the node/add form. This is because it could be a significant length of time between when the node form loads and the user actually submits the form to create the node.

Instead, Core (and Date Popup Authored) sets the date of the node at the time of submission if a date is not supplied. I'd rather not deviate from Core's usage, especially since there's a good reason.

That being said, there are three issues with your patch:

  • The patch presumes the date format for the popup is Y-m-d H:i:s O: this isn't necessarily true. It's set to the site's short format. Date Popup Authored converts the user's value to Core's expected format upon submit.
  • Using date() does not take into account the user's time zone: it'll use the server's time zone.
  • Setting #default_value to date('Y-m-d H:i:s O') overwrites any previously set values (like when the user edits the node).

If the default functionality—setting the post date to the time of submission if the authored field is blank—isn't working for you, please feel free to open a new issue.