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

Form errors not showing for checkboxes with Bootstrap 4

XMLWordPrintable

    • MOODLE_35_STABLE
    • MOODLE_35_STABLE
    • MDL-62376-master
    • Hide

      Testing this issue requires you to change some code to be able to check the test results:

      in mod/assign/mod_form.php after 

      $mform->addElement('header', 'general', get_string('general', 'form'));

      add:

      $mform->addElement('checkbox', 'checkbox1', 'checkbox');
      $mform->addElement('radio', 'radio1', 'radio', 1);
      $mform->addElement('advcheckbox', 'advcheckbox1', 'advanced', 'Label displayed after checkbox', array('group' => 1), array(0, 1));
      $testgroup=array();
      $testgroup[] = $mform->createElement('radio', 'radio2', '', 'radio1', 1, 'attributes');
      $testgroup[] = $mform->createElement('radio', 'radio3', '', 'radio2', 1, 'attributes');
      $mform->addGroup($testgroup, 'testgroup', '', array(' '), false);

      then in function validation() before:

      return $errors;

      add:

      $errors['radio1'] = 'error';
      $errors['checkbox1'] = 'error';
      $errors['advcheckbox1'] = 'error';
      $errors['testgroup'] = 'error';

      then start testing these using these steps:

      1. Log in as admin.
      2. Go to a course
      3. Add a new assignment
      4. The add assignment form should show the checkboxes and radios
      5. Only fill out the name field
      6. Save changes
      7. You should see notification messages on each checkbox type.
      Show
      Testing this issue requires you to change some code to be able to check the test results: in mod/assign/mod_form.php after  $mform->addElement('header', 'general', get_string('general', 'form')); add: $mform->addElement('checkbox', 'checkbox1', 'checkbox'); $mform->addElement('radio', 'radio1', 'radio', 1); $mform->addElement('advcheckbox', 'advcheckbox1', 'advanced', 'Label displayed after checkbox', array('group' => 1), array(0, 1)); $testgroup=array(); $testgroup[] = $mform->createElement('radio', 'radio2', '', 'radio1', 1, 'attributes'); $testgroup[] = $mform->createElement('radio', 'radio3', '', 'radio2', 1, 'attributes'); $mform->addGroup($testgroup, 'testgroup', '', array(' '), false); then in function validation() before: return $errors; add: $errors ['radio1'] = 'error'; $errors ['checkbox1'] = 'error'; $errors ['advcheckbox1'] = 'error'; $errors ['testgroup'] = 'error'; then start testing these using these steps: Log in as admin. Go to a course Add a new assignment The add assignment form should show the checkboxes and radios Only fill out the name field Save changes You should see notification messages on each checkbox type.

      To reproduce this, install https://moodle.org/plugins/quizaccess_honestycheck, and run the Behat test.

      If fails with

      C:\Users\tjh238\workspace\moodle_head>vendor\bin\behat.bat --config C:\Temp\moodle_head_data_behat\behatrun\behat\behat.yml --tags quizaccess_honestycheck
      Moodle 3.5beta+ (Build: 20180508), 55d6eadcaf6057e147e4b265b815778adf06369f
      Php: 7.1.14, pgsql: 9.3.4, OS: Windows NT 6.1 AMD64
      Server OS "WINNT", Browser: "chrome"
      Browser specific fixes have been applied. See http://docs.moodle.org/dev/Acceptance_testing#Browser_specific_fixes
      Started at 10-05-2018, 01:57
      ............................F-----------
       
      --- Failed steps:
       
      001 Scenario: Require students to agree, then check the they have to.
            # C:\Users\tjh238\workspace\moodle_head\mod\quiz\accessrule\honestycheck\tests\behat\basic_test.feature:21
            Then I should see "You must agree to this statement before you start the quiz." # C:\Users\tjh238\workspace\moodle_head\mod\quiz\accessrule\honestycheck\tests\behat\basic_test.feature:63
              "You must agree to this statement before you start the quiz." text was found but was not visible (Behat\Mink\Exception\ExpectationException)
       
      1 scenario (1 failed)
      40 steps (28 passed, 1 failed, 11 skipped)
      4m47.19s (68.44Mb)
      

      To see what is going on:

      1. Log in to you Behat test site as admin.
      2. Go into Course 1.
      3. Go into Quiz with honesty check.
      4. Click 'Start attempt'. A pop-up will open.
      5. Click 'Start attempt' in the pop-up, the page will re-load to show the form what was in the pop-up full-screen.
      6. At this point, the text 'You must agree to this statement before you start the quiz.' should be visiable as a form error beside the un-checked checkbox.

      In fact, that content is in the page, as

      <div class="form-control-feedback invalid-feedback" id="id_error_honestycheck">
                  You must agree to this statement before you start the quiz.
              </div>
      

      However, there is CSS that is hiding it. That looks to me like a bug caused by the Boostrap 4 work. Hence this bug report.

            basbrands Bas Brands
            timhunt Tim Hunt
            Tim Hunt Tim Hunt
            David Monllaó David Monllaó
            David Monllaó David Monllaó
            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.