Fwd: Calendar Issue ?

113 views
Skip to first unread message

Thomas PAPIN

unread,
Nov 4, 2012, 6:31:47 AM11/4/12
to joomla-de...@googlegroups.com
Hello,

I was using calendar field from a long time without having notice any issue, but finally I found something strange with joomla 2.5

I have a form with a date field (using calendar), the format is %m/%d/%Y.

On insertion there is no issue, I can select a date, and this date is well formatted.

The problem is with update (because there is a default value).
if I call calendar with 11/04/2012 for example with format %m/%d/%Y I got :
DateTime::__construct(): Failed to parse time string (11/04/2012) at position 0 (1): Unexpected character
If i call calendar with 2012-11-04, there is no error, but in the textfield (of the calendar field), the date is not formatted using my format. if I change the date, then the order is correct, but this is not good. because If I submit without changing the date, the format is not the one I wanted !

I check the joomla framework, and I can see:
title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '"

I don't know which we want to put a title on the input type ? It's not really necessary and If I remove this part, there is no more issue because the issue is due to JHTML::_('date') ?

So my questions is why do we have this "title" ? and why we call JHTML_('date') without the format given in the calendar function ??



2012/11/4 Thomas PAPIN <thomas...@gmail.com>
Hello,

I was using calendar field from a long time without having notice any issue, but finally I found something strange with joomla 2.5

I have a form with a date field (using calendar), the format is %m/%d/%Y.

On insertion there is no issue, I can select a date, and this date is well formatted.

The problem is with update (because there is a default value).
if I call calendar with 11/04/2012 for example with format %m/%d/%Y I got :
DateTime::__construct(): Failed to parse time string (11/04/2012) at position 0 (1): Unexpected character
If i call calendar with 2012-11-04, there is no error, but in the textfield (of the calendar field), the date is not formatted using my format. if I change the date, then the order is correct, but this is not good. because If I submit without changing the date, the format is not the one I wanted !

I check the joomla framework, and I can see:
title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '"

I don't know which we want to put a title on the input type ? It's not really necessary and If I remove this part, there is no more issue because the issue is due to JHTML::_('date') ?

So my questions is why do we have this "title" ? and why we call JHTML_('date') without the format given in the calendar function ??

Thomas PAPIN

unread,
Nov 5, 2012, 4:13:23 AM11/5/12
to joomla-de...@googlegroups.com, joomla-de...@googlegroups.com
No one ?

This is very strange behaviour. That's mean that you cannot use the calendar in a form without the default date format %Y-%m-%d. If you are using another format.

I think I will create a pull request for this on 2.5 CMS and the platform.

Elin Waring

unread,
Nov 5, 2012, 6:25:19 AM11/5/12
to joomla-de...@googlegroups.com, joomla-de...@googlegroups.com
You should not be using % in the date formats I know that. That's something that has to be changed in switching to JForm.

https://github.com/joomla/joomla-platform/issues/1467

I think is the same issue you are talking about?

I don't know about why the title stuff is there but with calendar I know that many things have been done to allow representation of of as many known calendars as possible.

Elin

Thomas PAPIN

unread,
Nov 5, 2012, 8:42:38 AM11/5/12
to joomla-de...@googlegroups.com, joomla-de...@googlegroups.com
Hello,

Thanks for your answer, I am able to format the date, the issue is only with the "default" value, so I don't think there is a link between the two issues.
I am not using also JForm, the form is generated manually.

You said: "You should not be using % in the date formats I know that"

I am not sure about that, maybe in JForm but in Joomla 2.5, the function in libraries/joomla/html/html.php :
public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
And my date format is correct, the calendar is generated 11-05-2012 and not %11-%05-%2012.

Just to clarify my issue:

$defaultdate= 11-05-2012;
echo JHTML::_('calendar', $defaultdate, "mydate", "mydate", "%m-%d-%Y", $options);
--> DateTime::__construct(): Failed to parse time string (11-05-2012) at position 0 (1): Unexpected character

The only solution currently is to set defaultdate = 2012-11-05 but in this case, the default value is not in the correct format.









2012/11/5 Elin Waring <elin....@gmail.com>
Reply all
Reply to author
Forward
0 new messages