quickapps / cms

Modular CMS powered by CakePHP
GNU General Public License v3.0
164 stars 69 forks source link

DateField Issues #165

Closed paulrwest closed 7 years ago

paulrwest commented 7 years ago

I have found several issues with the Date Field type.

Issue 1) Setting any kind of format breaks the add/edit form within admin with the following error:

'invalid date'

even though the date format is correct. removing all formatting is the only way to get the form to save.

Issue 2) DateToolbox::createFromFormat() always returns false.

\vendor\quickapps-plugins\field\src\Template\Element\DateField\display.ctp (line 18)

debug( $format );
debug( $field->extra );
debug($date);

'yy-mm-dd' '2016-12-25 11:291' false

\vendor\quickapps-plugins\field\src\Utility\DateToolbox.php (line 74) debug([$format, $date]);

[ (int) 0 => 'Y-n-j', (int) 1 => '2016-12-25 11:291' ]

all the above results in:

1970-1-1 00:001

I would recommend switching to using Cakes built in Time/Chronos class for date fields and drop using 'DateToolbox' and maybe give the user a few format choices that Chronos supports "nice", "date", "dateTime" etc.

botchris commented 7 years ago

DateToolbox class was created to convert jQuery's datepicker formats to PHP and vice versa, which allows more rich formatting, beyond to what Cake's Chronos may offer.

I'll take a look

botchris commented 7 years ago

please confirm if this patch solves the problem.

regards!

LeLuyen commented 7 years ago

Hi Chris, echo $field->view_mode_settings['format'];//always like 'yy-mm-dd' When I setting the field date with format like "mm-dd-yy" but format of the field date always is 'yy-mm-dd'. Please fix.

Thank you!

LeLuyen commented 7 years ago

Hi Chris, I'm sorry. It seems fixed on #b762a1a revision Thank you!

paulrwest commented 7 years ago

Thank you Chris for fixing this, so sorry I never got back to you, I got pulled off the CMS project but I'm back on it now and have updated and it seems to be working for me too.