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

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

XMLWordPrintable

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

      Use client side rules.

      Show
      Use client side rules.

      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.

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

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.