No Code Attached Yet bug
avatar prinswebdevelopment
prinswebdevelopment
17 Oct 2022

Steps to reproduce the issue

Joomla! 4 only
Build a form with this field:

save the form,
In FormController::save:623 ($validData = $model->validate($form, $data);)
the value 2022-10-17 change in 2022-10-17 10:06:12 (with the current time)

This arises in the class/method CalendarField::filter:352 ($value = DateTime::createFromFormat($this->filterFormat, $value)->format('Y-m-d H:i:s');)

I run into the problem where I have a form confirmed (by user) before I save it. When I save the form with the data in the session I get an error (Call to a member function format() on bool ) on the same method (CalendarField::filter:352) because the filterFormat doesn't know that format is changed.

Expected result

The time should not be added to the value.

Actual result

Time is added to the value.

System information (as much as possible)

PHP 8.1.2
Joomla! 4.2.3

Additional comments

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
5.00

avatar prinswebdevelopment prinswebdevelopment - open - 17 Oct 2022
avatar prinswebdevelopment prinswebdevelopment - change - 17 Oct 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 17 Oct 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Oct 2022
avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023
avatar ceford
ceford - comment - 3 May 2024

This problem is also present in 5.1! I created a subform and included in it two instances of a date field. The first time it saved with no problem. On the second save I got the fatal error: Call to a member function format() on false / JROOT/libraries/src/Form/Field/CalendarField.php:400. It seems the filte is Y-m-d but the value has time too.

This is a serious bug!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38978.

avatar Fedik
Fedik - comment - 3 May 2024

The first time it saved with no problem. On the second save I got the fatal error

That is diferent bug, the fix already there #43234

avatar ceford
ceford - comment - 3 May 2024

Thanks for that. I applied the patch and confirm I no longer get the fatal error.

avatar fuscage
fuscage - comment - 9 Aug 2024

I confirm the bug. I have the same problem.
When I used format="%Y-%m-%d" I receive a date filtered correctly.
But with php 8.2 I have a message "Deprecated: Function strftime() is deprecated ". I have see in this post #42790 to use filterFormat="Y-m-d" but that doesn't work :-(

Indeed with the code showed in this post that doesn't work : CalendarField::filter:352 ($value = DateTime::createFromFormat($this->filterFormat, $value)->format('Y-m-d H:i:s');)

Why you don't correct the code or replace the strftime() function ??? This issue is opened on Oct 17, 2022 :-( it's sad

avatar Quy
Quy - comment - 19 Sep 2024

Please test PR #44114

Add a Comment

Login with GitHub to post a comment