Home » Database » DB_Table » Bug #3892
Error in DB_Table_QuickForm->addElements
Details
| Submitted | 2005-03-20 15:03 UTC |
|---|---|
| From | pear at felixdd dot de |
| Assigned | pmjones |
| Status | Closed |
| Package | DB_Table |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-03-20 15:03 UTC] pear at felixdd dot de
Description:
------------
DB/Table/QuickForm.php,v 1.19
There is a
Fatal error: Call to a member function getName() on a non-object in ...PEAR/DB/Table/QuickForm.php on line 208
while trying to add an 'qf_type' => 'radio' -column
And the $col['qf_label'] after that isn't correct too.
Additionally there will be an warning
Invalid argument supplied for foreach() in line 403 of ...PEAR/DB/Table/QuickForm.php
if there is no 'qf_vals' provided in the columns definition.
[2005-04-02 20:23 UTC] post at markwiesemann dot de
I just ran into the same problem.
Solution for the first part ("Fatal error: ...")
Change line 168 (current CVS version) to:
$form->addGroup($element, $cols_keys[$k], $cols[$cols_keys[$k]]['label']);
Then add before the foreach loop the following line:
$cols_keys = array_keys($cols);
This way DB_Table passes (again [it was working in older versions]) the right values to QF.
[2005-04-02 20:41 UTC] post at markwiesemann dot de
Relating to the second part ("Invalid argument supplied for foreach() ..."):
The problem here is in function fixColDef:
line 649:
// array of acceptable values, typically for
// 'select' or 'radio'
if (! isset($col['qf_vals'])) {
$col['qf_vals'] = null;
}
and then line 690:
default:
if (isset($col['qf_vals'])) {
$col['qf_type'] = 'select';
} else {
$col['qf_type'] = 'text';
}
break;
This way the foreach loop in line 363 (current CVS version) loops over null value which causes a warning.
My suggestion:
Move the code from line 649 [if (! isset($col['qf_vals'])) ...] behind the switch statement and change the assignment from $col['qf_vals'] = null to $col['qf_vals'] = array().
I don't see any side effects by changing the code as described above.
[2005-04-02 20:47 UTC] post at markwiesemann dot de
Correction to my first comment:
line 168 has to be:
$form->addGroup($element, $cols_keys[$k],
$cols[$cols_keys[$k]]['qf_label']);
The difference is "qf_label" instead of "label". (Sorry for that but in my scripts I use "label" and output it myself, not by QF.)