PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #5161

Pseudo-element "date" is not complient with ISO8601

Details

Submitted2005-08-20 22:19 UTC
FromMarcin dot Dobrucki at nokia dot com
StatusWont fix
PackageHTML_QuickForm
PHP Version4.3.11
OSSolaris
Roadmaps(Not assigned)

Comments

[2005-08-20 22:19 UTC] Marcin dot Dobrucki at nokia dot com

Description:
------------
If one creates a pseudo-element 'date' in the format: Ymd, the values in the select boxes will be as follows:

<select name="_deadline[m]">
<option value="1" selected="selected">01</option>
<option value="2">02</option>
<option value="3">03</option>
...
</select>

I've run into a problem using the submited value in PEAR::Date, which excpect strict ISO8601 format; year must be a 4-digit value, month and day must be a two-digit value with leading zero for 1-9.

I was going to fill this in for PEAR::Date, but they are correct in following the standard.

Test script:
---------------
$f = new HTML_QuickForm('example_form');
...
$deadline_options = array ("language" => "en",
"format" => "Ymd",
"minYear" => $min_year,
"maxYear" => $min_year + 5);

$f->addElement('date', '_deadline', 'Deadline: ', $deadline_options);

Expected result:
----------------
...
<select name="_deadline[m]">
<option value="01" selected="selected">1</option>
<option value="02">2</option>
<option value="03">3</option>
...
</select>
...

Actual result:
--------------
...
<select name="_deadline[m]">
<option value="1" selected="selected">01</option>
<option value="2">02</option>
<option value="3">03</option>
...
</select>
...

[2005-08-21 21:32 UTC] Marcin dot Dobrucki at nokia dot com

Yes, I am well aware how I can bodge this with sprintf, thank you very much. What do you think I do now? However, it is somewhat of a nuisance to have to sprintf every single date I get from QuickForm (and I get a lot of them).

[2005-08-22 07:00 UTC] bmansion at mamasam dot com

You can also use applyFilter() on those date elements if their format does not satisfy you.

The 'format' option in the date element is used to format the way the date field is displayed, not the way the values are returned. Month values are always returned without leading 0. That's a rule.