Edit report at http://pear.php.net/bugs/bug.php?id=18439&edit=1
ID: 18439
Updated by: borz_off@cs.msu.su
Reported By: loki_angel at mail dot ru
Summary: Wrong messages order in JS
-Status: Open
+Status: Wont fix
Type: Bug
Package: HTML_QuickForm2
Package Version: 0.5.0
PHP Version: 5.2.12
Roadmap Versions:
New Comment:
-Status: Open
+Status: Wont fix
The proposed solution won't help much: messages for rules that are not
chained will appear in reverse order after applying it.
A more robust solution is not to rely on messages order at all, either
use just one message:
$login->addRule(
'nonempty', 'You must type login or OpenId', null,
HTML_QuickForm2_Rule::SERVER | HTML_QuickForm2_Rule::CLIENT
)->or_($openid->createRule('nonempty'));
or override form.validator.onInvalid() method to e.g. display error
messages near the relevant elements (similar to what DHTMLRulesTableless
package does).
Previous Comments:
------------------------------------------------------------------------
[2011-04-13 10:54:53] loki
Description:
------------
If i use chained rules with client verification, JS puts error in
reverse order.
In quickform.js string
ret.push(this._map[this._keys[i]]);
must be
ret.unshift(this._map[this._keys[i]]);
Test script:
---------------
$login->addRule('nonempty', 'You must type login'), null,
HTML_QuickForm2_Rule::SERVER |
HTML_QuickForm2_Rule::CLIENT)->or_($openid->createRule('nonempty', 'or
OpenId'));
Expected result:
----------------
Invalid information entered:
- You must type login
- or OpenId
Please correct these fields.
Actual result:
--------------
Invalid information entered:
- or OpenId
- You must type login
Please correct these fields.
------------------------------------------------------------------------