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

Unable to use more than one URL field type on a single Form page

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.4.3, 3.5
    • Fix Version/s: 3.4.5, 3.5.2
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      Please test on both Boost and Clean themes!!!!

      Multi URL test

      1. Download the attached test file, 'multi_url_test.php', and place in the root dir of your Moodle instance.
      2. Hit the page (http://YOUR_SITE/multi_url_test.php)
      3. Click inside the field for the third element (External URL 3), and then click somewhere else on the page.
      4. Verify that you see the form validation warning, stating that the field is required.
      5. Now, using the 'Choose a link' button for the third element (External URL 3), select an image from a wikimedia search and add it.
      6. Verify that the link is added to the third field (without the patch, this will fail)
      7. Verify that the third field has focus and that the validation warning is still present.
      8. Now, click somewhere else on the page, and confirm the validation warning disappears.
      9. Perform the same test for the first element, making sure to choose a different image to the one you just used.
      10. Verify the URL is added to the first field. (without the patch, this will also fail)
      11. Verify that after clicking away from the field, the validation warning again disappears.
      12. Now, find the URL of an image by searching google/whatever in another tab. Paste this URL into the second field.
      13. Now, submit the form.
      14. Verify you see a notice with the submitted URLs and that all 3 URLs correspond to the URLs you selected earlier.

      Regression test

      1. Create an instance of the URL resource in a course and Verify that it's created successfully.
      2. Edit the instance, and Verify the URL has persisted and is what you set in step 1.
      Show
      Please test on both Boost and Clean themes!!!! Multi URL test Download the attached test file, 'multi_url_test.php', and place in the root dir of your Moodle instance. Hit the page ( http://YOUR_SITE/multi_url_test.php) Click inside the field for the third element (External URL 3), and then click somewhere else on the page. Verify that you see the form validation warning, stating that the field is required. Now, using the 'Choose a link' button for the third element (External URL 3), select an image from a wikimedia search and add it. Verify that the link is added to the third field (without the patch, this will fail) Verify that the third field has focus and that the validation warning is still present. Now, click somewhere else on the page, and confirm the validation warning disappears. Perform the same test for the first element, making sure to choose a different image to the one you just used. Verify the URL is added to the first field. (without the patch, this will also fail) Verify that after clicking away from the field, the validation warning again disappears. Now, find the URL of an image by searching google/whatever in another tab. Paste this URL into the second field. Now, submit the form. Verify you see a notice with the submitted URLs and that all 3 URLs correspond to the URLs you selected earlier. Regression test Create an instance of the URL resource in a course and Verify that it's created successfully. Edit the instance, and Verify the URL has persisted and is what you set in step 1.
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-52318-master

      Description

      Installing and using the contrib plugin mod_tab, we noticed that we are unable to use "Choose a link..." button when we have several of those buttons (one for each tab) on the same Tab settings form page.

      Digging into this, I found that the mod_tab uses core repeat_elements() to generate URL form field for each Tab. as they are generated, each get a unique id (id_externalurl_0, id_externalurl_1, ... ) but the JS code that handles the returned URL from the filepicker is not aware of the multi URL form field instances and tries to set the value to "id_externalurl", as if there is no repetition of elements.
      https://github.com/moodle/moodle/blob/master/lib/form/url.js#L16

        Attachments

        1. 1.PNG
          1.PNG
          199 kB
        2. 2.PNG
          2.PNG
          29 kB
        3. multi_url_test.php
          2 kB

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/18

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 42 minutes
                  42m