FAQ
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.

------------------------------------------------------------------------

Search Discussions

  • Loki_angel at Apr 14, 2011 at 9:42 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18439&edit=1

    ID: 18439
    Comment by: loki_angel@mail.ru
    Reported By: loki_angel at mail dot ru
    Summary: Wrong messages order in JS
    Status: Wont fix
    Type: Bug
    Package: HTML_QuickForm2
    Package Version: 0.5.0
    PHP Version: 5.2.12
    Roadmap Versions:
    New Comment:

    Thank you for your answer!
    One message is the wrong path, number of fields can be large.
    Seems to improve the method form.validator.onInvalid() would be the best
    solution. Are you planning similar improvements in upcoming versions?


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-04-14 09:04:55] avb

    -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).

    ------------------------------------------------------------------------

    [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.

    ------------------------------------------------------------------------
  • Borz_off at Apr 14, 2011 at 10:09 am
    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: Wont fix
    Type: Bug
    Package: HTML_QuickForm2
    Package Version: 0.5.0
    PHP Version: 5.2.12
    Roadmap Versions:
    New Comment:

    Basically, yes.

    This is not the best place to discuss further package development,
    though, consider subscribing to pear-dev mailing list and asking the
    questions there.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-04-14 10:43:30] loki

    Thank you for your answer!
    One message is the wrong path, number of fields can be large.
    Seems to improve the method form.validator.onInvalid() would be the best
    solution. Are you planning similar improvements in upcoming versions?

    ------------------------------------------------------------------------

    [2011-04-14 09:04:55] avb

    -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).

    ------------------------------------------------------------------------

    [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.

    ------------------------------------------------------------------------
  • Loki_angel at Apr 15, 2011 at 9:21 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18439&edit=1

    ID: 18439
    Updated by: loki_angel@mail.ru
    Reported By: loki_angel at mail dot ru
    Summary: Wrong messages order in JS
    Status: Wont fix
    Type: Bug
    Package: HTML_QuickForm2
    Package Version: 0.5.0
    PHP Version: 5.2.12
    Roadmap Versions:
    New Comment:

    Sorry, but I do not want to subscribe to the mailing list.
    I sketched out a working draft of possible changes. It would be nice to
    see something like this in the next version.

    /**
    * Called on failed validation
    */
    qf.Validator.prototype.onInvalid = function()
    {
    this.removeErrorMessages();
    for(i=0; i<this.errors._keys.length; i++)
    {
    current=document.getElementById(this.errors._keys[i]);
    error=document.createElement('span');
    error.className='error';
    error.appendChild(document.createTextNode(this.errors._map[this.errors._keys[i]]));
    error.appendChild(document.createElement('br'));
    current.parentNode.insertBefore(error, current);
    }
    };

    qf.Validator.prototype.removeErrorMessages = function()
    {
    messages=document.getElementsByTagName('span');
    for (i=(messages.length-1); i>=0; i--)
    {
    if (messages[i].className=='error')
    messages[i].parentNode.removeChild(messages[i]);
    }
    }


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-04-14 11:10:55] avb

    Basically, yes.

    This is not the best place to discuss further package development,
    though, consider subscribing to pear-dev mailing list and asking the
    questions there.

    ------------------------------------------------------------------------

    [2011-04-14 10:43:30] loki

    Thank you for your answer!
    One message is the wrong path, number of fields can be large.
    Seems to improve the method form.validator.onInvalid() would be the best
    solution. Are you planning similar improvements in upcoming versions?

    ------------------------------------------------------------------------

    [2011-04-14 09:04:55] avb

    -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).

    ------------------------------------------------------------------------

    [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.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedApr 14, '11 at 8:03a
activeApr 15, '11 at 9:21a
posts4
users3
websitepear.php.net

People

Translate

site design / logo © 2022 Grokbase