PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #7443

how to default a date element to blank??

Details

Submitted2006-04-20 20:30 UTC
Fromrbradford at khov dot com
StatusBogus
PackageHTML_QuickForm
PHP Version5.1.1
OSWindowsXP
Roadmaps(Not assigned)

Comments

[2006-04-20 20:30 UTC] rbradford at khov dot com

Description:
------------
I have a form for handling help desk tickets. Each ticket has
a "due date" among other fields. This is not a required field
so I need to have the element default to blank and store a
NULL value if it is left blank. I got the form to show the
blanks using:

$builder->selectAddEmpty = array('due_date');

(I am using DB_DataObject_FormBuilder, however I believe this
deals with the HTML_QuickForm part of it)

If I go to edit a record the due date element ('d M Y')
populates with the current date by default.

I also tried using the setConstants method, but same thing.

Test script:
---------------
//Here's some code

$ticket = DB_DataObject::factory('hd_tickets');
$ticket->get($_POST['id']);
//...
$builder =& DB_DataObject_FormBuilder::create($ticket);
//...
$builder->dateElementFormat = 'd M Y';
$builder->selectAddEmpty = array('due_date');
//...
$renderer =& new HTML_QuickForm_Renderer_QuickHtml();
$form->accept($renderer);
//...
echo $renderer->toHtml($html_template);

Expected result:
----------------
If I load a ticket record that has a NULL value for a due date
then the due date element should show blanks and when it saved
with the date elements blank then it should keep the NULL
value

Actual result:
--------------
When I load a ticket record with a due date value of NULL then
the date element defaults to the current date. If I then
choose the blank options for each select and save it, the
value '0000-00-00' is stored.