Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dateTime field to autogenrate Entry title doesn't work on first save from CP #3151

Closed
kristiansp opened this issue Jul 25, 2018 · 6 comments

Comments

@kristiansp
Copy link

Description

I have an entry type that uses a dateTime field to auto-generate the posts title with this rule:
{showTime | date( 'Y-m-d H:i')}

Somehow it doesn’t work on the first save when creating an entry in Craft (the showTime fields is left blank, and the title is set to the publishing date instead). If I set the date/time again, and save the entry, the field retains its value, and the title is corrected to reflect the showTime field.

When I create entries programatically from a plugin, it works without issue.

I have another entry with a date field (not with time), which is not connected to the title. These entries save correctly and retain the value, also on the first save of a new entry.

Steps to reproduce

  1. Create entry type that uses a dateTime field to auto-generate the title
  2. Create a new entry in the Control Panel, set the date and time to whatever, and save the entry
  3. After entry is created, set the dateTime that was left blank and save again, and it will work

Additional info

  • Craft version: Craft Pro 3.0.16.1
  • PHP version: 7.1.12
  • Database driver & version: MySQL 5.6.38
  • Plugins & versions: N/A
@brandonkelly
Copy link
Member

Sorry not sure I’m following.

  1. Create a new entry in the Control Panel, set the date and time to whatever, and save the entry
  2. After entry is created, set the dateTime that was left blank and save again, and it will work

In step 2 you are saying to give the Date/Time field a value, but in step 3 you are saying that the Date/Time field should have been left blank. Which is it?

@kristiansp
Copy link
Author

kristiansp commented Jul 25, 2018

Sorry, I guess I was a bit unclear:

When I save the entry for the first time (step 2), I have set a value to the Date/Time field. When I save the entry, the field is blank, and instead of creating the title based on the date in the Date/Time field, it creates the title (in the format I have specified), but based on the published date instead.

Then, with the entry already created, if I set the Date/Time field again (step 3), it saves and retains its value, and the title is updated to reflect the value of the Date/Time field. Here's a couple of screenshots:

  1. Creating new setting, and setting the Date/Time
  2. After initial save, Date/Time is blank, and title is set based on Post Date
  3. Resetting the Date/Time
  4. After second save, the Date/Time is set, and the title is updated.

Hope that was a bit clearer!

1 -creating-new-entry-setting-datetime

2 -entry-saved-first-time

3 -resetting-datetime

4 -entry-saved-second-time

@brandonkelly
Copy link
Member

Ah gotcha, thanks for the clarification. Looking into it…

@brandonkelly
Copy link
Member

brandonkelly commented Jul 26, 2018

Unfortunately I’m not able to reproduce this. Can you please send us a database backup and your composer.json & composer.lock files, so we can try to reproduce it with your install? [email protected]

@kristiansp
Copy link
Author

Thanks for looking into this, I've sent the DB and the composer files now.

Just as a test, I tried adding a new field, and it had the same behaviour. When I tried to use a Date field (without time) it got even weirder – when picking tomorrow's date (July 29 2018), the Date (and title) was saved as June 7 2020(!)

brandonkelly added a commit that referenced this issue Jul 29, 2018
@brandonkelly
Copy link
Member

Tracked this down - this only happens when the entry’s site’s language is different than the user’s preferred language. Fixed for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants