Element: date - Issues

altnetwork

Member
I have an element using the date plugin.

1. under the Date Format Tab I have "Default to current date" set to yes. When I create a new record the date shows and is saved. When viewing the record I see the date.

2. I want to have the date update every time I edit the record. So, I set "Always return todays date" to yes. Now when I edit the record the current date is listed and saved/

3. The issue with that when "Always return todays date" is set to yes any record that was saved with a old date does not show in the view. What shows in the view is always the current date and not the date that is saved in that element.
 
Correct. The "Always return today's date" sets the date as the form is displayed for edit, not as it is submitted. On the principle that the user should see what is going to be recorded when they hit Save.

I think to achieve what you need, you would have to write a little PHP form submission plugin to set the date at submit time, something like ...

Code:
$formModel->updateFormData('yourtable___yourdate', date('Y-m-d H:i:s'));

Set that to run on edit, onBeforeProcess.

And turn off "return todays date" on the element.

-- hugh
 
I understand this. This is what I expected.

"Correct. The "Always return today's date" sets the date as the form is displayed for edit, not as it is submitted. On the principle that the user should see what is going to be recorded when they hit Save."

But what I am saying is when you are not editing the record by viewing you should see the date that was save. This is not what is happening. If I edit a record last week and then view the record today it should show a date when I edited the record last week. It does not. It shows today's date.
 
It is working now. Not sure what was causing it to now work yesterday. FYI, I have been having strange things happen when using Google Chrome.

Thanks
 
Hmm, I thought we set the date for "always return today" when we rendered the form, rather than on submission. But I may be wrong. But as long as it's working for you now ...

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top