A form builder for Ruby on Rails that’s compatible with the GOV.UK Design System.
MIT License
Bot releases are visible (Hide)
Published by peteryates over 2 years ago
Published by peteryates over 2 years ago
Change default_error_summary_turbo_prefix
from turbolinks
to turbo
- as everything else is geared towards getting up and running with the latest version of Rails it makes sense to target turbo by default. #345
To continue prefixing error summary links for turbolinks add this line to your config:
config.default_error_summary_turbo_prefix = 'turbolinks'
Run the quality check/guide building step using Ruby 3.1 instead of Ruby 3.0 because Nanoc switched to using the latest version of Psych's keyword argument style over positional #347
Published by peteryates almost 3 years ago
div
elements, never span
. Previously the form builder would render text arguments in span
and blocks in div
8189646p
tags 02c43fcmaster
to main
As the upgrade to GOV.UK Design System 4.0.0 will take some time, the 2.8 series of the form builder will continue to receive critical bug fixes but all new features will be for version 3.0.0 and above
Published by peteryates almost 3 years ago
#html_safe
on) error messages. It might be useful if additional formatting is needed within the error. It is disabled by default. Thanks @darokel for this one #330#build_classes
#323Published by peteryates almost 3 years ago
Published by peteryates about 3 years ago
data-
values to be affected. The logic has been flipped so only certain attributes (those that contain space-separated lists of values) will be merged and all others ignored. Thanks @baarkerlounger for diagnosing and reporting this #320Published by peteryates about 3 years ago
bold_labels
in radio button collections. Since the beginning the behaviour has been to flip the default to bold labels when the :description
is present, as it adds hints per option and they can blend into the labels. This approach didn't allow bold labels to be turned off when not wanted, so here we're changing the default from false
to nil
. When nil
, the old behaviour continues but when set to either true
or false
the setting will take precedence. Thanks @fofr for identifying and raising this. #316Published by peteryates about 3 years ago
presenter
argument for further customisation of the error summary list. The default presenter implements the current behaviour (it displays the first error for each attribute) but gives developers full control over the output. There's a new section in the guide covering its use. Many thanks to @jsugarman for this #311#compact#first
to #find(&:presence)
#308Published by peteryates over 3 years ago
Published by peteryates over 3 years ago
#govuk_check_box_divider
helper that works in exactly the same way as the radio button divider. It can be used to add a separator, "or" by default, to a list of checkboxes within a #govuk_check_boxes_fieldset
. Like the radio variant, the default text can be overridden via a config flagexclusive
keyword argument to #govuk_check_box
. Exclusive checkboxes will automatically uncheck their siblings when checked, and automatically become unchecked when any of their siblings become checked#builder_method
private, it doesn't need to be exposed. This was applied to all Element::Input
classes #297Published by peteryates over 3 years ago
Change #govuk_submit
so it renders a <button>
element instead of an <input type="submit">
. This is in response to #295 which highlights a longstanding bug with the design system where the top few pixels of the input element don't respond properly to clicks. The <button>
element should be functionally the same and any tests written using Capybara's click_button
style helpers should work, but it's probably going to break a few tests where assertions are made on the value
attribute, now they need to compare against the element's contents.
Additionally, as <button>
elements support any HTML inside them, we support passing a proc:
= govuk_submit(-> { tag.strong("Click me!" })
Thanks to @frankieroberto for reporting this #296
Switch any remaining specs that use nested #have_tag
over to #with_tag
syntax #294
Published by peteryates over 3 years ago
order:
argument or a default method can be assigned on models that the builder will look for (allowing the ordering to be set in one place and applied to all forms associated with the object). #290include GOVUKDesignSystemFormBuilder::BuilderHelper
. It currently has two methods that expose some form builder functionality to 'the outside'. Theres a sample PR here that shows how to get started. #268
govuk_field_id
- so you can override the id on custom form elements in a way that the builder's error summary can link to themgovuk_error_summary
- allows the error summary to be rendered outside of the form
Published by peteryates over 3 years ago
Published by peteryates over 3 years ago
FieldsetCheckBox
and FieldsetRadioButton
and their associated specs #2843.12.0
#280Published by peteryates over 3 years ago
Published by peteryates over 3 years ago
#govuk_select
helper. It is to #select
what #govuk_collection_select
is to #collection_select
. Allows more flexibility with option
and optgroup
elements, including the ability to add custom attributes. More info in the guide. Thanks to @AbigailMcP for suggesting this. #260Published by cpjmcquillan over 3 years ago
Published by peteryates over 3 years ago
The approach for setting custom HTML attributes has been standardised and now they are set via keyword arguments. Previously, the #govuk_collection_select
helper allowed a html_options
keyword argument (Rails-style), but this behaviour is no longer supported and will log a deprecation warning.
To upgrade, remove the html_options
kwarg and move the custom attributes to the method call:
- = govuk_collection_select :favourite_colour, @colours, :id, :name, html_options: { autofocus: false }
+ = govuk_collection_select :favourite_colour, @colours, :id, :name, autofocus: false
Published by peteryates over 3 years ago
formnovalidate
value to be configured #242Published by peteryates over 3 years ago
include_blank
support to #govuk_collection_check_boxes
. This brings the checkboxes variant of the collection helper in line with the radio buttons one. Thanks to @njseeto for reporting #238include_blank
arguments in line with Rails' defaults by setting them to true
by default. Previously the value was false
in #govuk_collection_radio_buttons
91db189af99b4c70include_blank
can be set for the check box and radio button helpers individually. To change the behaviour to how it was prior to 2.1.9
use this configuration:GOVUKDesignSystemFormBuilder.configure do |conf|
conf.default_collection_check_boxes_include_hidden = true
conf.default_collection_radio_buttons_include_hidden = false
end