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

Form elements editor and filepicker do not support freezing

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Download the attached test_editor_form.php and copy it to the root of your moodle test site.

      • navigate to yourmoodle/test_editor_form.php.
      • write a text (and add an image, if you like) in the editor area and submit the form.
      • reload the page. You can see your just written text in the editor window. You are in "read/write" mode so you can change or delete it.

      Modify the line 30 of the test_editor_form.php from:
      $editable = true;
      to
      $editable = false;

      • navigate again to yourmoodle/test_editor_form.php.
      • you are in "read only" mode. The just written text is no longer visible. This is the bug.

      Now apply the last patch provided here [MDL-29421-editor.patch] to head/lib/form/editor.php

      • navigate again to yourmoodle/test_editor_form.php.
      • you are still in "read only" mode but now you can see the written text and, as expected, you are no longer allowed to edit it.
      Show
      Download the attached test_editor_form.php and copy it to the root of your moodle test site. navigate to yourmoodle/test_editor_form.php. write a text (and add an image, if you like) in the editor area and submit the form. reload the page. You can see your just written text in the editor window. You are in "read/write" mode so you can change or delete it. Modify the line 30 of the test_editor_form.php from: $editable = true; to $editable = false; navigate again to yourmoodle/test_editor_form.php. you are in "read only" mode. The just written text is no longer visible. This is the bug. Now apply the last patch provided here [MDL-29421-editor.patch] to head/lib/form/editor.php navigate again to yourmoodle/test_editor_form.php. you are still in "read only" mode but now you can see the written text and, as expected, you are no longer allowed to edit it.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • Epic Link:
    • Pull 3.7 Branch:
    • Pull Master Branch:
      MDL-29421-master

      Description

      HTML_QuickForm_element has a nice feature called freezing. One can call $element->freeze() and element will be displayed as a static label+value pair plus a hidden field with a value.
      There is also an attribute _persistantFreeze (see method setPersistantFreeze), true by default. If set to false, no hidden field is generated.

      This feature is forgotten in the elements of type 'editor' and 'filepicker' (lib/form/editor.php and lib/form/filepicker.php)

      method toHtml() in both classes call getFrozenHtml() if element is frozen, but the classes do not redeclare the function getFrozenHtml()

      in case of filepicker, the draftitemid is displayed (could be list of files)
      in case of editor, warning is thrown because parent function assumes value to be a scalar. Also editor needs to redeclare hidden field generation in _getPersistantData() (or not use this function)

      the select field (lib/pear/HTML/QuickForm/select.php) can be used as an example of an element with an array stored in _value.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              marina Marina Glancy
              Peer reviewer:
              Tobias Reischmann
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated: