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

Static form fields have no id

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.5
    • Fix Version/s: FRONTEND
    • Component/s: Forms Library
    • Labels:
    • Affected Branches:
      MOODLE_25_STABLE

      Description

      Static form fields have no name or id values when rendered as html. I believe all form elements should now be given an id. It seems static fields have been missed.

      I just tried to append css to a specific static element in a form. Couldn't without the id. Works fine on all other elements.

      I'm editing the OU pmatch question type but this should apply to any form with static elements.

      The rendered html is
      <div class="fitem"><div class="fitemtitle"><div class="fstaticlabel"><label>Any other answer </label></div></div><div class="felement fstatic"> </div></div>

      A text field on the same form is rendered as
      <div id="fitem_id_answer_0" class="fitem fitem_ftextarea"><div class="fitemtitle"><label for="id_answer_0">Answer 1 </label></div><div class="felement ftextarea"><textarea rows="8" cols="60" class="textareamonospace" name="answer[0]" id="id_answer_0"></textarea></div></div>

      Notice the differing ids of the container divs fitem (static) compared to fitem_id_answer_0 (textarea).

      checked lib/form/static.php which led to quickform/static.php::toHtml().
      which doesn't print an attribute name. Compared it to select.php which does. However I think it's more complicated than just looking at the element class. The div containing both the label and the element needs the id.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              moodle.com moodle.com
              Reporter:
              colchambers Colin Chambers
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: