DB_Table, entering default date, while maintaining qf_type = 'date'?
| From: | Lloyd Leung | Date: | Sat, 14 Oct 2006 22:33:35 +0000 |
| Subject: | DB_Table, entering default date, while maintaining qf_type = 'date'? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25446@lists.php.net to get a copy of this message | ||
In the $cols definition, I assign the date.
However the date on the generated form becomes a text box,
not the normal date entry field.
i.e. it changes from 'qf_type' = 'date' to 'qf_type' =
'text'
I would like to be able to assign the default date (to today), while
maintaining the date entry field style.
My code http://pastebin.ca/203060
or
below
<?php
// Connection setup.
require_once 'DBConnect.php'
// basic classes
require_once 'MDB2.php';
require_once 'DB/Table.php';
class InvoiceUsers extends DB_Table {
var $col = array(
'id' => array('type' => 'integer',
'require'
=> true, 'qf_type'=>'hidden'),
'name' => array('type' => 'varchar',
'size' =>
32, 'qf_label'=> 'Name (e.g. "John Smith")',
'qf_attrs'=>
array('style'=>'background:#f00;')),
'address' => array('type' => 'clob',
'qf_type'=>
'textarea'),
'phone' => array('type' => 'varchar',
'size' =>
32, 'qf_type'=>'text', 'qf_label'=> 'Phone number') ,
'email' => array('type' => 'varchar',
'size' =>
128, 'require' => true ,'qf_type'=>'text'),
'signdate' => array('type' => 'date',
'qf_type'=>'date', 'require' => true)
);
var $idx = array(
'id' => 'unique'
);
};
$tablename = "testme";
$auto_create = 'safe';
$book =& new InvoiceUsers($mdb2, $tablename, $auto_create);
if ($book->error) {
echo "Failure! Try again.";
print_r($book->error);
die;
}
// setup what to display.
$cols = array(
'name' => '',
'address' => '',
'phone' => '',
'email' => '',
'date' => date('Y-m-d') // trying to figure out how to have today's
date as the default data
);
$form =& $book->getForm($cols);
// add a "submit" button named "op" that says "Go!"
$form->addElement('submit', 'op', 'Save');
// add a reset button
$form->addElement('reset', '', 'Reset');
$form->display();
?>
Thanks in advance.