Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-52243

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

    Details

    • Story Points:
      8

      Description

      This bug was incorrectly created as an AlloyUI bug, so I'm creating its equivalent on portal side and closing the AUI ticket. I'm not sure if this is still an issue, but thought it's best to open this anyway just to guarantee.

      Below follows the original text of the bug:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 48 weeks, 4 days ago

                  Packages

                  Version Package
                  7.0.0 M3