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 #4224

Allow export value for 'Date' elements to be collapsed to string

Details

Request #4224Allow export value for 'Date' elements to be collapsed to string
Submitted2005-04-26 11:39 UTC
Fromstudio at peptolab dot com
StatusWont fix
PackageHTML_QuickForm
PHP VersionIrrelevant
OSAny
Roadmaps(Not assigned)

Comments

[2005-04-26 11:39 UTC] studio at peptolab dot com

Description:
------------
Would it be possible to allow an option parameter to be
set (e.g. 'returnString' = true|false (default=false so
as not to break existing implementation)) so that a
form->exportValue() will return the value of the date
element as a string value rather than an array? I know
this could be achieved via a 'filter', but it would be a
lot simpler to allow this option from the constructor.
The returned string would be in the same Date() format
as the existing option parameter.

Reproduce code:
---------------
$options = array('returnString'=>true);
$el = $form->createElement('date','datefield','Enter date',$options);

$date = $form->exportValue('datefield');

RESULT:

20040426 (rather than [Y]=>2004, [m]=>04, [d]=>26);

[2005-04-27 13:45 UTC] studio at peptolab dot com

If it's so trivial, how does it get classed as bloat?!?
it would be more 'bloat' to have to add both a filter
and a function to each of my applications just to return
a value in a consistent format. Besides, you have to
assume that the function that returns the string knows
how the array was constructed in the first place, which
sounds even more convoluted.

It's a simple flag to allow programmers a cleaner way of
exporting data without having to further treat it. If
you can pass the date string as a parameter to it to
specify the format you want to capture the data, you
would surely expect that the value would be returned in
the same format.

[2005-04-27 14:17 UTC] bmansion at mamasam dot com

I agree with Alexey, it adds bloat.
The output format you require might suit your needs but not other people's. At least with an array, everyone can convert to the format they want.