x-govuk/govuk-form-builder

Add helper for generating a label only

Closed this issue · 0 comments

Usually a label is generated as part of the helper for the text input, as both the label and the input get wrapped in a "form group" container, which then gets a red border on the left when there’s an error present.

However there might be some rare occasions where it's best to generate the label separately, for example if the labels and inputs are within a table.

This would allow us to support this:

<tr>
  <th><%= f.govuk_label :price, "Price" %></th>
  <td><%= f.govuk_text_field :price, label: nil %></td>
</tr>