Re: Bug #624 [Opn->Asn]: FormBuilder bug caused by DataObject improvements
| From: | Norbert Mocsnik | Date: | Wed, 11 Feb 2004 09:10:44 +0000 |
| Subject: | Re: Bug #624 [Opn->Asn]: FormBuilder bug caused by DataObject improvements | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25580@lists.php.net to get a copy of this message | ||
I wanted to add the following comment to the bug report but I didn't succeed so here it is:
---8<---------->8---
A more forward compatible solution would be to use ifs instead of the switch structure.
if ($types & DB_DATAOBJECT_INT) {
[..code here..]
} elseif ($types & DB_DATAOBJECT_STR) {
[..code here..]
}
[..]
This looks like unstructured but keeps FormBuilder working even when another bit(s) will be used in DataObjects field specifications.
---8<---------->8---
Regards,
Norbert
PHP Bug Database wrote:
ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://pear.php.net/bugs/bug.php?id=624&edit=2ID: 624 Updated by: mw21st@php.net Reported By: pear-dev at mocsnik dot hu -Status: Open +Status: Assigned Bug Type: DB_DataObject_FormBuilderOperating System: irrelevantPHP Version: Irrelevant Assigned To: mw21stPrevious Comments: ------------------------------------------------------------------------ [2004-01-25 19:36:55] pear-dev at mocsnik dot hu Description: ------------ Some version of DB_DataObject introduced define('DB_DATAOBJECT_NOTNULL', 128); // not null col. besides the already existing types: define('DB_DATAOBJECT_INT', 1); // does not require '' define('DB_DATAOBJECT_STR', 2); // requires '' etc (DB_DataObject code) This results in unsure field type auto-detection in FormBuilders generateForm() method since it actually looks like: switch ($type) {case DB_DATAOBJECT_INT:(code here)[..]case DB_DATAOBJECT_TXT:(code here)[..] } Possible solution: a) switch ($type) {case DB_DATAOBJECT_INT:case DB_DATAOBJECT_INT+DB_DATAOBJECT_NOTNULL:(code here)[...]case DB_DATAOBJECT_TXT:case DB_DATAOBJECT_TXT+DB_DATAOBJECT_NOTNULL:(code here)[..] } Reproduce code: --------------- Any code using FormBuilder with NOT NULL fields (mysql specific??) Expected result: ---------------- Correct detection of field types. Actual result: -------------- Wrong type of input elements are generated because of not up-to-date field type auto-detection. ------------------------------------------------------------------------