Skip to content

Commit

Permalink
Added value attribute to render button
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Briggs committed Mar 3, 2025
1 parent 016a24d commit 180860c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ private String buildButtonAttributes(Map<String, String> attributes) {
buttonAttributes.append(" data-prevent-double-click=\"")
.append(attributes.get("preventDoubleClick")).append("\"");
}
if (attributes.containsKey("value")){
buttonAttributes.append(" value=\"").append(attributes.get("value")).append("\"");
}
return buttonAttributes.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void shouldRenderGovukButton() {
String renderedHtml = templateEngine.process("test-button", context);
assertThat(renderedHtml)
.contains("<a href=\"/test\" role=\"button\" draggable=\"false\" class=\"govuk-button custom-class\" data-module=\"govuk-button\" id=\"button-id\">Click Me!</a>")
.contains("<button type=\"submit\" disabled aria-disabled=\"true\" class=\"govuk-button\" data-module=\"govuk-button\" id=\"button-id\">Click Me!</button>");
.contains("<button type=\"submit\" disabled aria-disabled=\"true\" value=\"find_address\" class=\"govuk-button\" data-module=\"govuk-button\" id=\"button-id\">Click Me!</button>");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<govuk:button th:text="'Click Me!'" href="/test" id="button-id" classes="custom-class"/>

<govuk:button th:text="'Click Me!'" id="button-id" disabled/>
<govuk:button th:text="'Click Me!'" id="button-id" value="find_address" disabled/>

</body>
</html>

0 comments on commit 180860c

Please sign in to comment.