Boolean values and DataObject_FormBuilder
| From: | John Toven | Date: | Wed, 29 Sep 2004 13:41:03 +0000 |
| Subject: | Boolean values and DataObject_FormBuilder | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-14683@lists.php.net to get a copy of this message | ||
Hi all,
Any way to get DB_DataObject_FormBuilder to display checkboxes for
boolean fields in forms (mysql tinyints)? I've tried adding the
following code to the class extention
(http://marc.theaimsgroup.com/?l=pear-dev&m=107163769701468&w=2) but
with no luck. Any help much appreciated,
John
var $fb_booleanFields = array(
'fieldname' => 'descr',
Etc...
);
function preGenerateForm()
{
$this->preDefElements = array();
if (is_array($this->fb_booleanFields)) {
foreach ($this->fb_booleanFields as $field=>$description) {
$temp = &HTML_QuickForm::createElement('checkbox', $field,
$this->fb_fieldLabels[$field], $description);
$temp->setChecked($this->$field);
$this->preDefElements[$field] = &$temp;
}
}
}
function preProcess(&$values)
{
if (is_array($this->fb_booleanFields)) {
foreach (array_keys($this->fb_booleanFields) as $field) {
if ($values[$field] != 1) {
$values[$field] = 0;
}
}
}
}