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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Trivial
    • None
    • 2.5.1
    • Forms Library
    • MOODLE_25_STABLE
    • Hide

      Use client side rules.

      Show
      Use client side rules.

    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

              poltawski Dan Poltawski
              ankit_frenz Ankit Agarwal
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: