Uploaded image for project: 'PUBLIC - Liferay Alloy UI'
  1. PUBLIC - Liferay Alloy UI
  2. AUI-515

aui:input only uses id attribute for label and not for actual field.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Reorganized
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Taglibs
    • Labels:
      None

      Description

      I am attempting to add a "verify e-mail address" field to Liferay's account creation form (html/portlet/login/create_account.jsp). To do so, I added another aui:input tag under the existing e-mail field as follows:

      "Added field"
      <aui:input bean="<%= user2 %>" model="<%= User.class %>" name="emailAddress" label="emailAddress.verify" id="emailAddressVerify" />
      

      The field shows up correctly but the generated HTML is as follows:

      "Generated HTML (formatted)"
      <span class="aui-field aui-field-text" id="aui_3_2_0_1604">
        <span class="aui-field-content" id="aui_3_2_0_1603">
          <label class="aui-field-label" for="_58_emailAddressVerify"> Verify Email Address </label>
          <span class="aui-field-element " id="aui_3_2_0_1602">
              <input class="aui-field-input aui-field-input-text" id="_58_emailAddress" name="_58_emailAddress" style="width: 150px; " type="text" value="">
          </span>
        </span>
      </span>
      

      Notice that while the <label> tag has the correct "for" attribute, the actual <input> tag does not take the desired value of the ID attribute and remains "emailAddress" instead of "emailAddressVerify".

      It seems like page.jsp in the liferay-ui:input_field taglib is responsible, as it has the following line:

      "liferay_ui:input_field page.jsp"
      <input <%= Validator.isNotNull(cssClass) ? "class=\"" + cssClass + "\"" : StringPool.BLANK %> <%= disabled ? "disabled=\"disabled\"" : "" %> id="<%= namespace %><%= fieldParam %>" name="<%= namespace %><%= fieldParam %>" style="width: <%= displayWidth %><%= Validator.isDigit(displayWidth) ? "px" : "" %>; <%= upperCase ? "text-transform: uppercase;" : "" %>" type="<%= secret ? "password" : "text" %>" value="<%= autoEscape ? HtmlUtil.escape(value) : value %>" />
      

      Notice that the id and name are both set to the same "fieldParam" value.

      Edit: Downgrading to Minor since I can work around the issue by specifying the "fieldParam" attribute in the aui:input tag. I'm not actually submitting the e-mail verification field so I don't know how this affects updating the model but it solves the problem for my use case.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              maira.araujo Maíra Araujo (Inactive)
              Reporter:
              lyamamoto Leo Yamamoto (Inactive)
              Participants of an Issue:
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 44 weeks, 4 days ago

                  Packages

                  Version Package