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

minlength and maxlength rules do not work for mform elements of type 'editor'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.5.2, 2.6
    • Fix Version/s: None
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      Add this to mod/assign/mod_form.php

       $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'assign'));
       
                      $mform->addElement(
                     'editor',
                      'abc',     
                      "ABC",         
                      array('class' => 'form_input', 'canUseHtmlEditor'=>'detect', 'rows'=> '20', 'cols'=>'65')
              );
       
              $mform->addRule('abc', null, 'minlength', 10, 'client');                                                                    
              $mform->addRule('abc', null, 'maxlength', 50, 'client');                                        
              $mform->addRule('abc', null, 'required', null, 'client');      
      
      

      Add an assignment to a course.
      Verify that on saving the form you do not get the error in the description of this bug.

      Show
      Add this to mod/assign/mod_form.php $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'assign'));   $mform->addElement( 'editor', 'abc', "ABC", array('class' => 'form_input', 'canUseHtmlEditor'=>'detect', 'rows'=> '20', 'cols'=>'65') );   $mform->addRule('abc', null, 'minlength', 10, 'client'); $mform->addRule('abc', null, 'maxlength', 50, 'client'); $mform->addRule('abc', null, 'required', null, 'client'); Add an assignment to a course. Verify that on saving the form you do not get the error in the description of this bug.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE

      Description

      You get this error on submission:

      Warning: strlen() expects parameter 1 to be string, array given in /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/pear/HTML/QuickForm/Rule/Range.php on line 39 Call Stack: 0.0007 873472 1.

      {main}

      () /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/course/modedit.php:0 0.4074 65664936 2. moodleform->get_data() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/course/modedit.php:264 0.4075 65664936 3. moodleform->is_validated() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/formslib.php:622 0.4095 65663792 4. moodleform->validate_defined_fields() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/formslib.php:525 0.4095 65664112 5. HTML_QuickForm->validate() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/formslib.php:552 0.4098 65684920 6. HTML_QuickForm_RuleRegistry->validate() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/pear/HTML/QuickForm.php:1511 0.4098 65685000 7. HTML_QuickForm_Rule_Range->validate() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/pear/HTML/QuickForm/RuleRegistry.php:148 0.4098 65685080 8. strlen() /home/damyonw/Documents/Moodle/integration/MOODLE_25_STABLE/moodle/lib/pear/HTML/QuickForm/Rule/Range.php:39

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                damyon Damyon Wiese
                Participants:
                Component watchers:
                Jake Dallimore, Jun Pataleta
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: