Module: GOVUKDesignSystemFormBuilder::Builder
- Included in:
- FormBuilder
- Defined in:
- lib/govuk_design_system_formbuilder/builder.rb
Instance Method Summary collapse
-
#govuk_check_box(attribute_name, value, unchecked_value = false, hint: {}, label: {}, link_errors: false, multiple: true, exclusive: false, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a single check box, intended for use within a #govuk_check_boxes_fieldset.
-
#govuk_check_box_divider(text = config.default_check_box_divider_text) ⇒ ActiveSupport::SafeBuffer
Inserts a text divider into a list of check boxes.
-
#govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint: {}, small: false, form_group: {}, multiple: true, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generate a fieldset intended to conatain one or more #govuk_check_box.
-
#govuk_collection_check_boxes(attribute_name, collection, value_method, text_method, hint_method = nil, hint: {}, legend: {}, caption: {}, small: false, form_group: {}, include_hidden: config.default_collection_check_boxes_include_hidden, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generate a list of check boxes from a collection.
-
#govuk_collection_radio_buttons(attribute_name, collection, value_method, text_method = nil, hint_method = nil, hint: {}, legend: {}, caption: {}, inline: false, small: false, bold_labels: nil, include_hidden: config.default_collection_radio_buttons_include_hidden, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a radio button for each item in the supplied collection.
-
#govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, hint: {}, label: {}, caption: {}, form_group: {}, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a
selectelement containingoptionfor each member in the provided collection. -
#govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, segments: config.default_date_segments, segment_names: config.default_date_segment_names, before_inputs: nil, after_inputs: nil, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates three inputs for the
day,monthandyearcomponents of a date. -
#govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type
email. -
#govuk_error_summary(title = config.default_error_summary_title, presenter: config.default_error_summary_presenter, link_base_errors_to: nil, order: nil, **kwargs, &block) ⇒ Object
Generates a summary of errors in the form, each linking to the corresponding part of the form that contains the error.
-
#govuk_fieldset(legend: { text: 'Fieldset heading' }, caption: {}, described_by: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a fieldset containing the contents of the block.
-
#govuk_file_field(attribute_name, label: {}, caption: {}, hint: {}, form_group: {}, javascript: false, before_input: nil, after_input: nil, choose_files_button_text: nil, drop_instruction_text: nil, multiple_files_chosen_text: nil, no_file_chosen_text: nil, entered_drop_zone_text: nil, left_drop_zone_text: nil, **kwargs, &block) ⇒ Object
Generates an input of type
file. -
#govuk_label(attribute_name, text: nil, size: nil, hidden: false, tag: nil, caption: nil, **kwargs) ⇒ Object
Generates a form label without a form group or input.
-
#govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type
number. -
#govuk_password_field(attribute_name, hint: {}, label: {}, caption: {}, form_group: {}, show_password_text: config.default_show_password_text, hide_password_text: config.default_hide_password_text, show_password_aria_label_text: config.default_show_password_aria_label_text, hide_password_aria_label_text: config.default_hide_password_aria_label_text, password_shown_announcement_text: config.default_password_shown_announcement_text, password_hidden_announcement_text: config.default_password_hidden_announcement_text, **kwargs, &block) ⇒ Object
Generates a password input.
-
#govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type
tel. -
#govuk_radio_button(attribute_name, value, hint: {}, label: {}, link_errors: false, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a radio button.
-
#govuk_radio_buttons_fieldset(attribute_name, hint: {}, legend: {}, caption: {}, inline: false, small: false, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a radio button fieldset container and injects the supplied block contents.
-
#govuk_radio_divider(text = config.default_radio_divider_text) ⇒ ActiveSupport::SafeBuffer
Inserts a text divider into a list of radio buttons.
-
#govuk_select(attribute_name, choices = nil, options: {}, label: {}, hint: {}, form_group: {}, caption: {}, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a
selectelement containing anoptionfor every choice provided. -
#govuk_submit(text = config.default_submit_button_text, warning: false, secondary: false, inverse: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a submit button, green by default.
-
#govuk_text_area(attribute_name, hint: {}, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group: {}, description_other_text: nil, under_limit_other_text: nil, under_limit_one_text: nil, at_limit_text: nil, over_limit_one_text: nil, over_limit_other_text: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a
textareaelement with a label, optional hint. -
#govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type
text. -
#govuk_time_field(attribute_name, hint: {}, legend: {}, caption: {}, omit_second: false, maxlength_enabled: false, segments: config.default_time_segments, segment_names: config.default_time_segment_names, before_inputs: nil, after_inputs: nil, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates three inputs for the
hour,minuteandsecondcomponents of a time. -
#govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type
url.
Instance Method Details
#govuk_check_box(attribute_name, value, unchecked_value = false, hint: {}, label: {}, link_errors: false, multiple: true, exclusive: false, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a single check box, intended for use within a #govuk_check_boxes_fieldset
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 912 def govuk_check_box(attribute_name, value, unchecked_value = false, hint: {}, label: {}, link_errors: false, multiple: true, exclusive: false, **kwargs, &block) Elements::CheckBoxes::FieldsetCheckBox.new( self, object_name, attribute_name, value, unchecked_value, hint:, label:, link_errors:, multiple:, exclusive:, **kwargs, &block ).html end |
#govuk_check_box_divider(text = config.default_check_box_divider_text) ⇒ ActiveSupport::SafeBuffer
This should only be used from within a #govuk_check_boxes_fieldset
Inserts a text divider into a list of check boxes
937 938 939 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 937 def govuk_check_box_divider(text = config.default_check_box_divider_text) tag.div(text, class: %w(govuk-checkboxes__divider)) end |
#govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint: {}, small: false, form_group: {}, multiple: true, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
To ensure the #govuk_error_summary link functions correctly ensure the first #govuk_check_box is set to link_errors: true
Generate a fieldset intended to conatain one or more #govuk_check_box
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 866 def govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint: {}, small: false, form_group: {}, multiple: true, **kwargs, &block) Containers::CheckBoxesFieldset.new( self, object_name, attribute_name, hint:, legend:, caption:, small:, form_group:, multiple:, **kwargs, &block ).html end |
#govuk_collection_check_boxes(attribute_name, collection, value_method, text_method, hint_method = nil, hint: {}, legend: {}, caption: {}, small: false, form_group: {}, include_hidden: config.default_collection_check_boxes_include_hidden, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generate a list of check boxes from a collection
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 808 def govuk_collection_check_boxes(attribute_name, collection, value_method, text_method, hint_method = nil, hint: {}, legend: {}, caption: {}, small: false, form_group: {}, include_hidden: config.default_collection_check_boxes_include_hidden, **kwargs, &block) Elements::CheckBoxes::Collection.new( self, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint:, legend:, caption:, small:, form_group:, include_hidden:, **kwargs, &block ).html end |
#govuk_collection_radio_buttons(attribute_name, collection, value_method, text_method = nil, hint_method = nil, hint: {}, legend: {}, caption: {}, inline: false, small: false, bold_labels: nil, include_hidden: config.default_collection_radio_buttons_include_hidden, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Unlike the Rails #collection_radio_buttons helper, this version can also insert hints per item in the collection by supplying a :hint_method
:bold_labels, is nil (falsy) by default. When a :hint_method is provided it will become true to make the label stand out more from the hint. The choice can be overridden with true or false.
Generates a radio button for each item in the supplied collection
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 629 def (attribute_name, collection, value_method, text_method = nil, hint_method = nil, hint: {}, legend: {}, caption: {}, inline: false, small: false, bold_labels: nil, include_hidden: config., form_group: {}, **kwargs, &block) Elements::Radios::Collection.new( self, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint:, legend:, caption:, inline:, small:, bold_labels:, form_group:, include_hidden:, **kwargs, &block ).html end |
#govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, hint: {}, label: {}, caption: {}, form_group: {}, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a select element containing option for each member in the provided collection
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 501 def govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, hint: {}, label: {}, caption: {}, form_group: {}, before_input: nil, after_input: nil, **kwargs, &block) Elements::CollectionSelect.new( self, object_name, attribute_name, collection, value_method:, text_method:, hint:, label:, caption:, options:, form_group:, before_input:, after_input:, **kwargs, &block ).html end |
#govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, segments: config.default_date_segments, segment_names: config.default_date_segment_names, before_inputs: nil, after_inputs: nil, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
When using this input be aware that Rails’s multiparam time and date handling falls foul of this bug, so incorrect dates like 2019-09-31 will be ‘rounded’ up to 2019-10-01.
When using this input values will be retrieved from the attribute if it is a Date object or a multiparam date hash
Generates three inputs for the day, month and year components of a date
1026 1027 1028 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 1026 def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, segments: config.default_date_segments, segment_names: config.default_date_segment_names, before_inputs: nil, after_inputs: nil, form_group: {}, **kwargs, &block) Elements::Date.new(self, object_name, attribute_name, hint:, legend:, caption:, date_of_birth:, omit_day:, maxlength_enabled:, segments:, segment_names:, form_group:, before_inputs:, after_inputs:, **kwargs, &block).html end |
#govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type email
181 182 183 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 181 def govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) Elements::Inputs::Email.new(self, object_name, attribute_name, hint:, label:, caption:, width:, extra_letter_spacing:, form_group:, prefix_text:, suffix_text:, before_input:, after_input:, **kwargs, &block).html end |
#govuk_error_summary(title = config.default_error_summary_title, presenter: config.default_error_summary_presenter, link_base_errors_to: nil, order: nil, **kwargs, &block) ⇒ Object
Only the first error in the #errors array for each attribute will be included.
Generates a summary of errors in the form, each linking to the corresponding part of the form that contains the error
1106 1107 1108 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 1106 def govuk_error_summary(title = config.default_error_summary_title, presenter: config.default_error_summary_presenter, link_base_errors_to: nil, order: nil, **kwargs, &block) Elements::ErrorSummary.new(self, object_name, title, link_base_errors_to:, order:, presenter:, **kwargs, &block).html end |
#govuk_fieldset(legend: { text: 'Fieldset heading' }, caption: {}, described_by: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a fieldset containing the contents of the block
1139 1140 1141 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 1139 def govuk_fieldset(legend: { text: 'Fieldset heading' }, caption: {}, described_by: nil, **kwargs, &block) Containers::Fieldset.new(self, legend:, caption:, described_by:, **kwargs, &block).html end |
#govuk_file_field(attribute_name, label: {}, caption: {}, hint: {}, form_group: {}, javascript: false, before_input: nil, after_input: nil, choose_files_button_text: nil, drop_instruction_text: nil, multiple_files_chosen_text: nil, no_file_chosen_text: nil, entered_drop_zone_text: nil, left_drop_zone_text: nil, **kwargs, &block) ⇒ Object
Remember to set multipart: true when creating a form with file uploads, see the Rails documentation for more information
Generates an input of type file
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 1189 def govuk_file_field( attribute_name, label: {}, caption: {}, hint: {}, form_group: {}, javascript: false, before_input: nil, after_input: nil, choose_files_button_text: nil, drop_instruction_text: nil, multiple_files_chosen_text: nil, no_file_chosen_text: nil, entered_drop_zone_text: nil, left_drop_zone_text: nil, **kwargs, &block ) Elements::File.new( self, object_name, attribute_name, label:, caption:, hint:, form_group:, javascript:, before_input:, after_input:, choose_files_button_text:, drop_instruction_text:, multiple_files_chosen_text:, no_file_chosen_text:, entered_drop_zone_text:, left_drop_zone_text:, **kwargs, &block ).html end |
#govuk_label(attribute_name, text: nil, size: nil, hidden: false, tag: nil, caption: nil, **kwargs) ⇒ Object
Generates a form label without a form group or input
15 16 17 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 15 def govuk_label(attribute_name, text: nil, size: nil, hidden: false, tag: nil, caption: nil, **kwargs) GOVUKDesignSystemFormBuilder::Elements::Label.new(self, object_name, attribute_name, text:, size:, hidden:, tag:, caption:, **kwargs).html end |
#govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type number
292 293 294 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 292 def govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) Elements::Inputs::Number.new(self, object_name, attribute_name, hint:, label:, caption:, width:, extra_letter_spacing:, form_group:, prefix_text:, suffix_text:, before_input:, after_input:, **kwargs, &block).html end |
#govuk_password_field(attribute_name, hint: {}, label: {}, caption: {}, form_group: {}, show_password_text: config.default_show_password_text, hide_password_text: config.default_hide_password_text, show_password_aria_label_text: config.default_show_password_aria_label_text, hide_password_aria_label_text: config.default_hide_password_aria_label_text, password_shown_announcement_text: config.default_password_shown_announcement_text, password_hidden_announcement_text: config.default_password_hidden_announcement_text, **kwargs, &block) ⇒ Object
Generates a password input
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 326 def govuk_password_field( attribute_name, hint: {}, label: {}, caption: {}, form_group: {}, show_password_text: config.default_show_password_text, hide_password_text: config.default_hide_password_text, show_password_aria_label_text: config.default_show_password_aria_label_text, hide_password_aria_label_text: config.default_hide_password_aria_label_text, password_shown_announcement_text: config.default_password_shown_announcement_text, password_hidden_announcement_text: config.default_password_hidden_announcement_text, **kwargs, &block ) Elements::Password.new( self, object_name, attribute_name, hint:, label:, caption:, form_group:, show_password_text:, hide_password_text:, show_password_aria_label_text:, hide_password_aria_label_text:, password_shown_announcement_text:, password_hidden_announcement_text:, **kwargs, &block ).html end |
#govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type tel
127 128 129 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 127 def govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) Elements::Inputs::Phone.new(self, object_name, attribute_name, hint:, label:, caption:, width:, extra_letter_spacing:, form_group:, prefix_text:, suffix_text:, before_input:, after_input:, **kwargs, &block).html end |
#govuk_radio_button(attribute_name, value, hint: {}, label: {}, link_errors: false, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
This should only be used from within a #govuk_radio_buttons_fieldset
Generates a radio button
731 732 733 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 731 def (attribute_name, value, hint: {}, label: {}, link_errors: false, **kwargs, &block) Elements::Radios::FieldsetRadioButton.new(self, object_name, attribute_name, value, hint:, label:, link_errors:, **kwargs, &block).html end |
#govuk_radio_buttons_fieldset(attribute_name, hint: {}, legend: {}, caption: {}, inline: false, small: false, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
The intention is to use #govuk_radio_button and #govuk_radio_divider within the passed-in block
To ensure the #govuk_error_summary link functions correctly ensure the first #govuk_radio_button is set to link_errors: true
Generates a radio button fieldset container and injects the supplied block contents
699 700 701 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 699 def (attribute_name, hint: {}, legend: {}, caption: {}, inline: false, small: false, form_group: {}, **kwargs, &block) Containers::RadioButtonsFieldset.new(self, object_name, attribute_name, hint:, legend:, caption:, inline:, small:, form_group:, **kwargs, &block).html end |
#govuk_radio_divider(text = config.default_radio_divider_text) ⇒ ActiveSupport::SafeBuffer
This should only be used from within a #govuk_radio_buttons_fieldset
Inserts a text divider into a list of radio buttons
743 744 745 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 743 def govuk_radio_divider(text = config.default_radio_divider_text) tag.div(text, class: %(#{config.brand}-radios__divider)) end |
#govuk_select(attribute_name, choices = nil, options: {}, label: {}, hint: {}, form_group: {}, caption: {}, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a select element containing an option for every choice provided
554 555 556 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 554 def govuk_select(attribute_name, choices = nil, options: {}, label: {}, hint: {}, form_group: {}, caption: {}, before_input: nil, after_input: nil, **kwargs, &block) Elements::Select.new(self, object_name, attribute_name, choices, options:, label:, hint:, form_group:, caption:, before_input:, after_input:, **kwargs, &block).html end |
#govuk_submit(text = config.default_submit_button_text, warning: false, secondary: false, inverse: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Only the first additional button or link (passed in via a block) will be given the correct left margin, subsequent buttons will need to be manually accounted for
This helper always renders an <button type=‘submit’> tag. Previous versions of this gem rendered a +‘<input type=’submit’>‘ tag instead, but there is a longstanding bug with this approach where the top few pixels don’t initiate a submission when clicked.
Generates a submit button, green by default
971 972 973 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 971 def govuk_submit(text = config., warning: false, secondary: false, inverse: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block) Elements::Submit.new(self, text, warning:, secondary:, inverse:, prevent_double_click:, validate:, disabled:, **kwargs, &block).html end |
#govuk_text_area(attribute_name, hint: {}, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group: {}, description_other_text: nil, under_limit_other_text: nil, under_limit_one_text: nil, at_limit_text: nil, over_limit_one_text: nil, over_limit_other_text: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Setting max_chars or max_words will add a caption beneath the textarea with a live count of words or characters
Generates a textarea element with a label, optional hint. Also offers the ability to add the GOV.UK character and word counting components automatically
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 417 def govuk_text_area( attribute_name, hint: {}, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group: {}, description_other_text: nil, under_limit_other_text: nil, under_limit_one_text: nil, at_limit_text: nil, over_limit_one_text: nil, over_limit_other_text: nil, **kwargs, &block ) Elements::TextArea.new( self, object_name, attribute_name, hint:, label:, caption:, max_words:, max_chars:, rows:, threshold:, form_group:, description_other_text:, under_limit_other_text:, under_limit_one_text:, at_limit_text:, over_limit_one_text:, over_limit_other_text:, **kwargs, &block ).html end |
#govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type text
71 72 73 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 71 def govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) Elements::Inputs::Text.new(self, object_name, attribute_name, hint:, label:, caption:, width:, extra_letter_spacing:, form_group:, prefix_text:, suffix_text:, before_input:, after_input:, **kwargs, &block).html end |
#govuk_time_field(attribute_name, hint: {}, legend: {}, caption: {}, omit_second: false, maxlength_enabled: false, segments: config.default_time_segments, segment_names: config.default_time_segment_names, before_inputs: nil, after_inputs: nil, form_group: {}, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
When using this input values will be retrieved from the attribute if it is a Time object or a multiparam date hash
Generates three inputs for the hour, minute and second components of a time
1076 1077 1078 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 1076 def govuk_time_field(attribute_name, hint: {}, legend: {}, caption: {}, omit_second: false, maxlength_enabled: false, segments: config.default_time_segments, segment_names: config.default_time_segment_names, before_inputs: nil, after_inputs: nil, form_group: {}, **kwargs, &block) Elements::Time.new(self, object_name, attribute_name, hint:, legend:, caption:, omit_second:, maxlength_enabled:, segments:, segment_names:, form_group:, before_inputs:, after_inputs:, **kwargs, &block).html end |
#govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) ⇒ ActiveSupport::SafeBuffer
Generates a input of type url
235 236 237 |
# File 'lib/govuk_design_system_formbuilder/builder.rb', line 235 def govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, before_input: nil, after_input: nil, **kwargs, &block) Elements::Inputs::URL.new(self, object_name, attribute_name, hint:, label:, caption:, width:, extra_letter_spacing:, form_group:, prefix_text:, suffix_text:, before_input:, after_input:, **kwargs, &block).html end |