x-govuk / govuk-form-builder

A form builder for Ruby on Rails that’s compatible with the GOV.UK Design System.
https://govuk-form-builder.netlify.app
MIT License
75 stars 21 forks source link

Consider how to support content before and after inputs within a form group #478

Open frankieroberto opened 8 months ago

frankieroberto commented 8 months ago

This feature was added to the Nunjucks macros in Add beforeInput(s) and afterInput(s) options to form groups (#4567).

We could consider how we might support this too.

frankieroberto commented 8 months ago

One option is to have separate helpers for the form group and the label:

<%= f.govuk_form_group :price do %>
  <%= f.govuk_label :price, "Price" %>
  Content
  <%= f.govuk_text_field :price, label: nil, form_group: nil %>
  More content
<% end %>

Another option is to add before_input and after_input options to the existing helper, which would more closely follow the Nunjucks macro, but is maybe a bit unconventional for Rails?:

<%= f.govuk_text_field :price, 
  label: { text: "Price" }, 
  form_group: { before_input: "Content", after_input: "More content" } 
%>