Module: GOVUKDesignSystemFormBuilder
- 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/elements/time.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/password.rb,
lib/govuk_design_system_formbuilder/traits/date_input.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/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/traits/data_attributes_i18n.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/traits/content_before_and_after.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
-
:brandsets the value used to prefix all classes, used to allow the builder to be branded for alternative (similar) design systems. -
:default_caption_sizecontrols the default size of caption text. Can be eitherxl,lorm. -
:default_legend_sizecontrols the default size of legend text. Can be eitherxl,l,mors. -
:default_legend_tagcontrols the default tag that legends are wrapped in. Defaults tonil. -
:default_submit_button_textsets the value assigned togovuk_submit, defaults to 'Continue'. -
:default_date_segmentsallows the date segments used by Rails' multiparameter attributes to be configured. This is useful if you want to override the standard behaviour where Rails tries to cast the values into aDate. Defaults to{ day: '3i', month: '2i', year: '1i' } -
:default_date_segment_namesallows the individual date field labels to have their default values set. Defaults to{ day: 'Day', month: 'Month', year: 'Year' } -
:default_radio_divider_textsets the text automatically added to the radio button divider, defaults to 'or' -
:default_check_box_divider_textsets the text automatically added to the checkbox divider, defaults to 'or' -
:default_collection_check_boxes_include_hiddencontrols whether or not a hidden field is added when rendering a collection of check boxes -
:default_collection_radio_buttons_include_hiddencontrols whether or not a hidden field is added when rendering a collection of radio buttons -
:default_collection_radio_buttons_auto_bold_labelswill automatically make labels on #govuk_collection_radio_buttons bold when a:hint_methodis present. The default can be overridden using thebold_labels:argument. The default value is 'true'. -
:default_error_message_prefixsets the prefix text inserted before inline errors added to form inputs. It defaults to 'Error'. -
:default_error_summary_titlesets 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_presenterthe class that's instantiated when rendering an error summary and formats the messages for each attribute -
:default_error_summary_error_order_methodis 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_prefixis 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 -
:default_text_area_description_textsets the text that's displayed beneath the text area when word counts are enabled. Defaults to nil -
:default_text_area_words_under_limit_other_textsets the text displayed when the user is approaching the limit of words. Defaults to "You have %count words remaining" -
:default_text_area_words_under_limit_one_textsets the text that's displayed when the user is 1 word below the limit. Defaults to "You have %count word remaining" -
:default_text_area_words_at_limit_textsets the text that's displayed when the user has reached the limit. Defaults to "You have 0 words remaining" -
:default_text_area_words_over_limit_other_textsets the text displayed when the user is more than 1 word above the limit. Defaults to "You have %count words too many" -
:default_text_area_words_over_limit_one_textsets the text that's displayed when the user is 1 word above the limit. Defaults to "You have %count word too many" -
:default_text_area_characters_under_limit_other_textsets the text displayed when the user is approaching the limit of characters. Defaults to "You have %count characters remaining" -
:default_text_area_characters_under_limit_one_textsets the text that's displayed when the user is 1 character below the limit. Defaults to "You have %count character remaining" -
:default_text_area_characters_at_limit_textsets the text that's displayed when the user has reached the limit. Defaults to "You have 0 characters remaining" -
:default_text_area_characters_over_limit_other_textsets the text displayed when the user is more than 1 character above the limit. Defaults to "You have %count characters too many" -
:default_text_area_characters_over_limit_one_textsets the text that's displayed when the user is 1 character above the limit. Defaults to "You have %count character too many" -
:default_show_password_textButton text when the password is hidden. Defaults to 'Show' -
:default_hide_password_textButton text when the password is revealed. Defaults to 'Hide' -
:default_show_password_aria_label_textButton text exposed to assistive technologies like screen readers, when the password is hidden. Defaults to "Show password" -
:default_hide_password_aria_label_textButton text exposed to assistive technologies like screen readers, when the password is visible. Defaults to "Hide password". -
:default_password_shown_announcement_textAnnouncement made to screen reader users when their password has become visible in plain text. Defaults to "Your password is visible" -
:default_password_hidden_announcement_textAnnouncement made to screen reader users when their password has been obscured and is not visible. Defaults to "Your password is hidden" -
:default_file_choose_files_button_textThe text of the button that opens the file picker. Default is "Choose file". If javascript is not provided, this option will be ignored -
:default_file_drop_instruction_textThe text informing users they can drop files. Default is "or drop file". If javascript is not provided, this option will be ignore -
:default_file_no_file_chosen_textThe text displayed when no file has been chosen by the user. Default is "No file chosen". If javascript is not provided, this option will be ignored -
:default_file_multiple_files_chosen_one_textThe text displayed when multiple files are enabled and one file has been chosen by the user. The component will replace the %count placeholder with the number of files selected. If javascript is not provided, this option will be ignored. Defaults to 'One file chosen' -
:default_file_multiple_files_chosen_other_textThe text displayed when multiple files are enabled and multiple files have been chosen by the user. The component will replace the %count placeholder with the number of files selected. If javascript is not provided, this option will be ignored. Defaults to '%count files chosen' -
:default_file_entered_drop_zoneThe text announced by assistive technology when user drags files and enters the drop zone. Default is "Entered drop zone". If javascript is not provided, this option will be ignored -
:default_file_left_drop_zoneThe text announced by assistive technology when user drags files and leaves the drop zone without dropping. Default is "Left drop zone". If javascript is not provided, this option will be ignored. -
:localisation_schema_fallbacksets 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_hintand:localisation_schema_labeleach override the schema root for their particular context, allowing them to be independently customised. -
:enable_loggercontrols whether or not the library will emit log messages via Rails.logger.warn, defaults totrue -
:trust_error_messagescall 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 -
:enable_nested_localisationscan the object name before building the localisation schema path to see if it's nested or not. The old behaviour can be restored by setting this option tofalse. Defaults totrue
===
-
{ brand: 'govuk', default_legend_size: 'm', default_legend_tag: nil, default_caption_size: 'm', default_submit_button_text: 'Continue', default_date_segments: { day: '3i', month: '2i', year: '1i' }, default_date_segment_names: { day: 'Day', month: 'Month', year: 'Year' }, default_time_segments: { hour: '4i', minute: '5i', second: '6i' }, default_time_segment_names: { hour: 'Hour', minute: 'Minute', second: 'Second' }, default_radio_divider_text: 'or', default_check_box_divider_text: 'or', default_error_message_prefix: 'Error', 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_collection_radio_buttons_auto_bold_labels: 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, # temporarily allow the new nested localisation functionality to be # disabled enable_nested_localisation: true, **GOVUK_FRONTEND_DEFAULTS }.freeze
Constant Summary collapse
- GOVUK_FRONTEND_DEFAULTS =
{ # password field default_show_password_text: 'Show', default_hide_password_text: 'Hide', default_show_password_aria_label_text: 'Show password', default_hide_password_aria_label_text: 'Hide password', default_password_shown_announcement_text: 'Your password is visible', default_password_hidden_announcement_text: 'Your password is hidden', # text area (character count) default_text_area_description_text: nil, default_text_area_words_under_limit_other_text: 'You have %{count} words remaining', default_text_area_words_under_limit_one_text: 'You have %{count} word remaining', default_text_area_words_at_limit_text: 'You have 0 words remaining', default_text_area_words_over_limit_other_text: 'You have %{count} words too many', default_text_area_words_over_limit_one_text: 'You have %{count} word too many', default_text_area_characters_under_limit_other_text: 'You have %{count} characters remaining', default_text_area_characters_under_limit_one_text: 'You have %{count} character remaining', default_text_area_characters_at_limit_text: 'You have 0 characters remaining', default_text_area_characters_over_limit_other_text: 'You have %{count} characters too many', default_text_area_characters_over_limit_one_text: 'You have %{count} character too many', # file upload default_file_choose_files_button_text: 'Choose file', default_file_drop_instruction_text: 'or drop file', default_file_no_file_chosen_text: 'No file chosen', default_file_multiple_files_chosen_one_text: 'One file chosen', default_file_multiple_files_chosen_other_text: '%{count} files chosen', default_file_entered_drop_zone: 'Entered drop zone', default_file_left_drop_zone: 'Left drop zone', }.freeze
- VERSION =
'6.3.0'.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 Summary collapse
-
.inherited(klass) ⇒ Object
:nodoc:.
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
280 281 282 |
# File 'lib/govuk_design_system_formbuilder.rb', line 280 def configure yield config end |
.inherited(klass) ⇒ Object
:nodoc:
14 15 16 17 |
# File 'lib/govuk_design_system_formbuilder.rb', line 14 def inherited(klass) # :nodoc: klass.config = ActiveSupport::InheritableOptions.new(config) super 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
288 289 290 291 292 |
# File 'lib/govuk_design_system_formbuilder.rb', line 288 def reset! configure do |c| DEFAULTS.each { |k, v| c.send("#{k}=", v) } end end |