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

CalendarField add time in filter also if showtime=false #38978

Open
prinswebdevelopment opened this issue Oct 17, 2022 · 5 comments
Open

CalendarField add time in filter also if showtime=false #38978

prinswebdevelopment opened this issue Oct 17, 2022 · 5 comments

Comments

@prinswebdevelopment
Copy link

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

@ceford
Copy link
Contributor

ceford commented May 3, 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.

@Fedik
Copy link
Member

Fedik commented May 3, 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

@ceford
Copy link
Contributor

ceford commented May 3, 2024

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

@fuscage
Copy link

fuscage commented Aug 9, 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

@Quy
Copy link
Contributor

Quy commented Sep 19, 2024

Please test PR #44114

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

No branches or pull requests

7 participants