cvs: pear /DB_DataObject_FormBuilder FormBuilder.php

From: Date: Fri, 27 May 2005 04:25:03 +0000
Subject: cvs: pear /DB_DataObject_FormBuilder FormBuilder.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-32150@lists.php.net to get a copy of this message
justinpatrin Fri May 27 00:25:03 2005 EDT Modified files: /pear/DB_DataObject_FormBuilder FormBuilder.php Log: use fieldsRequired to alter type and use $type & DB_DATAOBJECT_NOTNULL instead of $notNull http://cvs.php.net/diff.php/pear/DB_DataObject_FormBuilder/FormBuilder.php?r1=1.180&r2=1.181&ty=u Index: pear/DB_DataObject_FormBuilder/FormBuilder.php diff -u pear/DB_DataObject_FormBuilder/FormBuilder.php:1.180 pear/DB_DataObject_FormBuilder/FormBuilder.php:1.181 --- pear/DB_DataObject_FormBuilder/FormBuilder.php:1.180 Thu May 26 23:58:58 2005 +++ pear/DB_DataObject_FormBuilder/FormBuilder.php Fri May 27 00:25:02 2005 @@ -94,7 +94,7 @@ * @author Justin Patrin <papercrane@reversefold.com> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version $Id: FormBuilder.php,v 1.180 2005/05/27 03:58:58 justinpatrin Exp $ + * @version $Id: FormBuilder.php,v 1.181 2005/05/27 04:25:02 justinpatrin Exp $ * @link http://pear.php.net/package/DB_DataObject_FormBuilder * @see DB_DataObject, HTML_QuickForm */ @@ -1063,7 +1063,6 @@ } else { unset($element); // Try to determine field types depending on object properties - $notNull = $type & DB_DATAOBJECT_NOTNULL; if (in_array($key, $this->dateFields)) { $type = DB_DATAOBJECT_DATE; } elseif (in_array($key, $this->timeFields)) { @@ -1075,6 +1074,9 @@ } elseif (in_array($key, $this->booleanFields)) { $type = DB_DATAOBJECT_BOOL; } + if (in_array($key, $this->fieldsRequired)) { + $type |= DB_DATAOBJECT_NOTNULL; + } if (isset($this->preDefElements[$key]) && (is_object($this->preDefElements[$key]) || is_array($this->preDefElements[$key]))) { @@ -1082,7 +1084,7 @@ $element =& $this->preDefElements[$key]; } elseif (isset($links[$key])) { // If this field links to another table, display selectbox or radiobuttons - $opt = $this->getSelectOptions($key, false, !$notNull); + $opt = $this->getSelectOptions($key, false, !($type & DB_DATAOBJECT_NOTNULL)); if (isset($this->linkElementTypes[$key]) && $this->linkElementTypes[$key] == 'radio') { $element =& $this->_form->_createRadioButtons($key, $opt); } else { @@ -1363,8 +1365,7 @@ $options = $newOptions; }*/ if (in_array($key, $this->selectAddEmpty) - || (!$notNull - && !in_array($key, $this->fieldsRequired))) { + || !($type & DB_DATAOBJECT_NOTNULL)) { $options = array_merge(array('' => $this->selectAddEmptyLabel), $options); } if (!$options) { @@ -1448,10 +1449,9 @@ //ADD REQURED RULE FOR NOT_NULL FIELDS if ((!in_array($key, $keys) || $this->hidePrimaryKey == false) - && ($notNull) + && ($type & DB_DATAOBJECT_NOTNULL) && !in_array($key, $elements_to_freeze) - && !($type & DB_DATAOBJECT_BOOL) - || in_array($key, $this->fieldsRequired)) { + && !($type & DB_DATAOBJECT_BOOL)) { $this->_form->_setFormElementRequired($key); $this->debug('Adding required rule for '.$key); }

« previous php.pear.cvs (#32150) next »