Module: GOVUKDesignSystemFormBuilder
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/govuk_design_system_formbuilder.rb,
lib/govuk_design_system_formbuilder/base.rb,
lib/govuk_design_system_formbuilder/proxy.rb,
lib/govuk_design_system_formbuilder/builder.rb,
lib/govuk_design_system_formbuilder/version.rb,
lib/govuk_design_system_formbuilder/traits/hint.rb,
lib/govuk_design_system_formbuilder/traits/error.rb,
lib/govuk_design_system_formbuilder/traits/input.rb,
lib/govuk_design_system_formbuilder/traits/label.rb,
lib/govuk_design_system_formbuilder/elements/date.rb,
lib/govuk_design_system_formbuilder/elements/file.rb,
lib/govuk_design_system_formbuilder/elements/hint.rb,
lib/govuk_design_system_formbuilder/elements/null.rb,
lib/govuk_design_system_formbuilder/traits/select.rb,
lib/govuk_design_system_formbuilder/builder_helper.rb,
lib/govuk_design_system_formbuilder/elements/label.rb,
lib/govuk_design_system_formbuilder/traits/caption.rb,
lib/govuk_design_system_formbuilder/elements/legend.rb,
lib/govuk_design_system_formbuilder/elements/select.rb,
lib/govuk_design_system_formbuilder/elements/submit.rb,
lib/govuk_design_system_formbuilder/elements/caption.rb,
lib/govuk_design_system_formbuilder/containers/radios.rb,
lib/govuk_design_system_formbuilder/elements/text_area.rb,
lib/govuk_design_system_formbuilder/containers/fieldset.rb,
lib/govuk_design_system_formbuilder/elements/inputs/url.rb,
lib/govuk_design_system_formbuilder/traits/html_classes.rb,
lib/govuk_design_system_formbuilder/traits/localisation.rb,
lib/govuk_design_system_formbuilder/traits/supplemental.rb,
lib/govuk_design_system_formbuilder/elements/inputs/text.rb,
lib/govuk_design_system_formbuilder/traits/fieldset_item.rb,
lib/govuk_design_system_formbuilder/containers/form_group.rb,
lib/govuk_design_system_formbuilder/elements/inputs/email.rb,
lib/govuk_design_system_formbuilder/elements/inputs/phone.rb,
lib/govuk_design_system_formbuilder/containers/check_boxes.rb,
lib/govuk_design_system_formbuilder/elements/error_message.rb,
lib/govuk_design_system_formbuilder/elements/error_summary.rb,
lib/govuk_design_system_formbuilder/elements/inputs/number.rb,
lib/govuk_design_system_formbuilder/traits/collection_item.rb,
lib/govuk_design_system_formbuilder/traits/html_attributes.rb,
lib/govuk_design_system_formbuilder/containers/button_group.rb,
lib/govuk_design_system_formbuilder/containers/supplemental.rb,
lib/govuk_design_system_formbuilder/elements/inputs/password.rb,
lib/govuk_design_system_formbuilder/containers/character_count.rb,
lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb,
lib/govuk_design_system_formbuilder/elements/collection_select.rb,
lib/govuk_design_system_formbuilder/elements/radios/collection.rb,
lib/govuk_design_system_formbuilder/refinements/prefixable_array.rb,
lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb,
lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb,
lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb,
lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb,
lib/govuk_design_system_formbuilder/elements/check_boxes/fieldset_check_box.rb,
lib/govuk_design_system_formbuilder/elements/radios/collection_radio_button.rb,
lib/govuk_design_system_formbuilder/elements/check_boxes/collection_check_box.rb
Defined Under Namespace
Modules: Builder, BuilderHelper, Containers, Elements, PrefixableArray, Traits Classes: Base, FormBuilder, FormBuilderProxy, Proxy
Defaults collapse
- DEFAULTS =
Default form builder configuration
-
:brand
sets the value used to prefix all classes, used to allow the builder to be branded for alternative (similar) design systems. -
:default_caption_size
controls the default size of caption text. Can be eitherxl
,l
orm
. -
:default_legend_size
controls the default size of legend text. Can be eitherxl
,l
,m
ors
. -
:default_legend_tag
controls the default tag that legends are wrapped in. Defaults tonil
. -
:default_submit_button_text
sets the value assigned togovuk_submit
, defaults to 'Continue'. -
:default_radio_divider_text
sets the text automatically added to the radio button divider, defaults to 'or' -
:default_check_box_divider_text
sets the text automatically added to the checkbox divider, defaults to 'or' -
:default_submit_button_text
sets the text used to divide the last radio button in radio button fieldsets. As per the GOV.UK Design System spec, it defaults to 'or'. -
:default_collection_check_boxes_include_hidden
controls whether or not a hidden field is added when rendering a collection of check boxes -
:default_collection_radio_buttons_include_hidden
controls whether or not a hidden field is added when rendering a collection of radio buttons -
:default_error_summary_title
sets the text used in error summary blocks. As per the GOV.UK Design System spec, it defaults to 'There is a problem'. -
:default_error_summary_presenter
the class that's instantiated when rendering an error summary and formats the messages for each attribute -
:default_error_summary_error_order_method
is the method that the library will check for on the bound object to see whether or not to try ordering the error messages -
:default_error_summary_turbo_prefix
is used to disable turbo/turbolinks from handling clicks on links in the error summary. When it's a string (eg, turbo), that will result in links with the attribute 'data-turbo=false'. When nil, no data attribute will be added. Defaults to turbo since Rails 7, change to 'turbolinks' for Rails 6.1 -
:localisation_schema_fallback
sets the prefix elements for the array used to build the localisation string. The final two elements are always are the object name and attribute name. The special value __context__, is used as a placeholder for the context (label, fieldset or hint). -
:localisation_schema_legend
,:localisation_schema_hint
and:localisation_schema_label
each override the schema root for their particular context, allowing them to be independently customised. -
:enable_logger
controls whether or not the library will emit log messages via Rails.logger.warn, defaults totrue
-
:trust_error_messages
call html_safe on error messages before they're rendered. This allows formatting markup to be used to change the display of the error message. Defaults tofalse
-
{ brand: 'govuk', default_legend_size: 'm', default_legend_tag: nil, default_caption_size: 'm', default_submit_button_text: 'Continue', default_radio_divider_text: 'or', default_check_box_divider_text: 'or', default_error_summary_title: 'There is a problem', default_error_summary_presenter: Presenters::ErrorSummaryPresenter, default_error_summary_error_order_method: nil, default_error_summary_turbo_prefix: 'turbo', default_collection_check_boxes_include_hidden: true, default_collection_radio_buttons_include_hidden: true, default_submit_validate: false, localisation_schema_fallback: %i(helpers __context__), localisation_schema_label: nil, localisation_schema_hint: nil, localisation_schema_legend: nil, localisation_schema_caption: nil, enable_logger: true, trust_error_messages: false, }.freeze
Constant Summary collapse
- VERSION =
'3.0.3'.freeze
Defaults collapse
-
.configure {|config| ... } ⇒ Object
Configure the form builder in the usual manner.
-
.reset! ⇒ Object
Resets each of the configurable values to its default.
Class Method Details
.configure {|config| ... } ⇒ Object
Configure the form builder in the usual manner. All of the keys in DEFAULTS can be configured as per the example below
118 119 120 |
# File 'lib/govuk_design_system_formbuilder.rb', line 118 def configure yield(config) end |
.reset! ⇒ Object
This method is only really intended for use to clean up during testing
Resets each of the configurable values to its default
126 127 128 129 130 |
# File 'lib/govuk_design_system_formbuilder.rb', line 126 def reset! configure do |c| DEFAULTS.each { |k, v| c.send("#{k}=", v) } end end |