Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-40813

Server side addRule() applies after clean_param(), making it not useful

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 2.5.1
    • Fix Version/s: BACKEND
    • Component/s: Forms Library
    • Labels:
    • Workaround:
      Hide

      Use client side rules.

      Show
      Use client side rules.
    • Affected Branches:
      MOODLE_25_STABLE

      Description

      clean_param() is always called before addrule() validations are checked in mforms
      For example :-

              $mform->addElement('text', 'config_appid', get_string('appid', 'block_fbcomments'));
              $mform->addHelpButton("config_appid", "appid", "block_fbcomments");
              $mform->addRule('config_appid', get_string("notnumeric", "block_fbcomments"), "numeric", null, "server");
              $mform->setType('config_appid', PARAM_INT);
              $mform->disabledIf('config_appid', 'config_enablecomment', 'notchecked');
      

      Will accept "test" as appid, since setype filters it and converts it to 0, which is then passed to add rule() which validates it as correct.
      However if you try doing the same thing without "settype", you get an error, since the "test" is not numeric.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: