Home » HTML » HTML_QuickForm » Bug #243
Syntax Error in Global Validation Rules
Details
| Submitted | 2003-11-14 09:36 UTC |
|---|---|
| From | imho at auspantheon dot com |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | n/a |
| Roadmaps | (Not assigned) |
Comments
[2003-11-14 09:36 UTC] imho at auspantheon dot com
Description:
------------
On line 1290, the line:
$this->_errors += $res;
I believe it should be: =+
Resulting Error:
Fatal error: Unsupported operand types in /usr/share/pear/HTML/QuickForm.php on line 1290
Reproduce code:
---------------
This error can be reproduced by submitting to the page where the form was constructed,using a form which doesn't contain a required element.
[2003-11-14 09:44 UTC] imho at auspantheon dot com
I don't know why =+ fixes the problem, but it does cause problems in normal QuickForm use.
I do not know the solution, I'll leave that to the developers.
As for the expected behaviour, I would expect the QuickForm to trigger the 'required' rule and display appropriatly.
Thanks for your time.
[2003-11-15 00:35 UTC] imho at auspantheon dot com
<?
function _is_student($fields)
{
if (!isset($fields['student']))
return false;
if (in_array($fields['student'], $this->_students))
return true;
return array('student' => 'No such student found.');
}
?>
Above is my custom function, a var_dump of $res ($this->_errors += $res;) shows that when $res is false (as returned by my function when $fields['student'] does not exist) will crash the script.
I'm sorry if you feel I'm wasting your time, however your rudeness is not appreciated.
As for an "obviously broken" fix,
The line (if ($res === false) continue;) added into the loop above ($this->_errors += $res;) seems to fix the problem, and displays the expected result.