govuk_design_system_formbuilder 1.2.5 → 2.0.0b3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/govuk_design_system_formbuilder.rb +1 -1
  4. data/lib/govuk_design_system_formbuilder/base.rb +1 -1
  5. data/lib/govuk_design_system_formbuilder/builder.rb +196 -90
  6. data/lib/govuk_design_system_formbuilder/containers/character_count.rb +1 -1
  7. data/lib/govuk_design_system_formbuilder/containers/check_boxes.rb +1 -1
  8. data/lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb +9 -9
  9. data/lib/govuk_design_system_formbuilder/containers/fieldset.rb +1 -1
  10. data/lib/govuk_design_system_formbuilder/containers/form_group.rb +4 -3
  11. data/lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb +10 -10
  12. data/lib/govuk_design_system_formbuilder/containers/radios.rb +1 -1
  13. data/lib/govuk_design_system_formbuilder/containers/supplemental.rb +1 -1
  14. data/lib/govuk_design_system_formbuilder/elements/caption.rb +10 -5
  15. data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb +12 -12
  16. data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection_check_box.rb +7 -5
  17. data/lib/govuk_design_system_formbuilder/elements/check_boxes/fieldset_check_box.rb +8 -4
  18. data/lib/govuk_design_system_formbuilder/elements/date.rb +11 -11
  19. data/lib/govuk_design_system_formbuilder/elements/error_message.rb +3 -3
  20. data/lib/govuk_design_system_formbuilder/elements/error_summary.rb +3 -3
  21. data/lib/govuk_design_system_formbuilder/elements/file.rb +8 -8
  22. data/lib/govuk_design_system_formbuilder/elements/hint.rb +35 -8
  23. data/lib/govuk_design_system_formbuilder/elements/inputs/email.rb +0 -2
  24. data/lib/govuk_design_system_formbuilder/elements/inputs/number.rb +0 -2
  25. data/lib/govuk_design_system_formbuilder/elements/inputs/password.rb +0 -2
  26. data/lib/govuk_design_system_formbuilder/elements/inputs/phone.rb +0 -2
  27. data/lib/govuk_design_system_formbuilder/elements/inputs/text.rb +0 -2
  28. data/lib/govuk_design_system_formbuilder/elements/inputs/url.rb +0 -2
  29. data/lib/govuk_design_system_formbuilder/elements/label.rb +20 -14
  30. data/lib/govuk_design_system_formbuilder/elements/legend.rb +18 -10
  31. data/lib/govuk_design_system_formbuilder/elements/radios/collection.rb +14 -14
  32. data/lib/govuk_design_system_formbuilder/elements/radios/collection_radio_button.rb +11 -5
  33. data/lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb +13 -5
  34. data/lib/govuk_design_system_formbuilder/elements/select.rb +11 -11
  35. data/lib/govuk_design_system_formbuilder/elements/text_area.rb +6 -6
  36. data/lib/govuk_design_system_formbuilder/traits/caption.rb +1 -9
  37. data/lib/govuk_design_system_formbuilder/traits/collection_item.rb +1 -1
  38. data/lib/govuk_design_system_formbuilder/traits/conditional.rb +1 -1
  39. data/lib/govuk_design_system_formbuilder/traits/hint.rb +15 -2
  40. data/lib/govuk_design_system_formbuilder/traits/input.rb +8 -8
  41. data/lib/govuk_design_system_formbuilder/version.rb +1 -1
  42. metadata +11 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 702ad71c46989cfeb455ced19e6c9c426685947bac6c6057f902bf1deb44eb97
4
- data.tar.gz: 263eda546cf3f17b3611613e77c0f24f9c52995015752c4cc534f914b0c689be
3
+ metadata.gz: bde738d424db57a56e70d3c397f166bc9b9cbacb833d4fa934ca3b8e4ad9422e
4
+ data.tar.gz: dc3445c229c5e1c7ceb5a24a576aa35546e1cd643f40828896680f2474bf9c57
5
5
  SHA512:
6
- metadata.gz: 063007b8ff7a1ab6c2bb1c470b36895047217d8149b84fb1a9b8aac12b0a3d5e7910828bd0e44bc2aafafa972f4c5f032bea0bc55cd7ae60fe99c32a716a9156
7
- data.tar.gz: 20cd7ac352b111277d57843b810eebb6cb73ef50c719501115b8a6f91264abd4b34646431c6ae9794df88378c0ee4f0bc835c7a5c633b3b251003581b0353664
6
+ metadata.gz: 2a3c4e32556ec7b57a3031ce19e53ab4a90ff1651b5de3c0cd047497efd488d8626689d65c18c9024f1886490841803c01ee8fdb3940e4d842d8190c28a565b4
7
+ data.tar.gz: '0729f505bb2980b2dd6c3b96c238c8e46eeea3477c0520a564f042896a84a600d97d76dd382a21ff83c32a184544081a80100b2cc2c14b59812275bcdea91e02'
data/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/fde73b5dc9476197281b/test_coverage)](https://codeclimate.com/github/DFE-Digital/govuk_design_system_formbuilder/test_coverage)
8
8
  [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=DFE-Digital/govuk_design_system_formbuilder)](https://dependabot.com)
9
9
  [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk_design_system_formbuilder)](https://github.com/DFE-Digital/govuk_design_system_formbuilder/blob/master/LICENSE)
10
- [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.7.0-brightgreen)](https://design-system.service.gov.uk)
10
+ [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.8.1-brightgreen)](https://design-system.service.gov.uk)
11
11
 
12
12
  This gem provides a easy-to-use form builder that generates forms that are
13
- fully-compliant with version 3.7.0 of the [GOV.UK Design System](https://design-system.service.gov.uk/),
13
+ fully-compliant with version 3.8.1 of the [GOV.UK Design System](https://design-system.service.gov.uk/),
14
14
  minimising the amount of markup you need to write.
15
15
 
16
16
  In addition to the basic markup, the more-advanced functionality of the Design
@@ -88,7 +88,7 @@ module GOVUKDesignSystemFormBuilder
88
88
  end
89
89
 
90
90
  class FormBuilder < ActionView::Helpers::FormBuilder
91
- delegate :content_tag, :tag, :safe_join, :safe_concat, :capture, :link_to, :raw, to: :@template
91
+ delegate :content_tag, :tag, :safe_join, :link_to, :capture, to: :@template
92
92
 
93
93
  include GOVUKDesignSystemFormBuilder::Builder
94
94
  end
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  end
9
9
 
10
10
  class Base
11
- delegate :capture, :content_tag, :safe_join, :tag, :raw, :link_to, to: :@builder
11
+ delegate :content_tag, :safe_join, :tag, :link_to, :capture, to: :@builder
12
12
  delegate :config, to: GOVUKDesignSystemFormBuilder
13
13
 
14
14
  def initialize(builder, object_name, attribute_name, &block)
@@ -5,7 +5,11 @@ module GOVUKDesignSystemFormBuilder
5
5
  # Generates a input of type +text+
6
6
  #
7
7
  # @param attribute_name [Symbol] The name of the attribute
8
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
8
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
9
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
10
+ # @option hint text [String] the hint text
11
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
12
+ #
9
13
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
10
14
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
11
15
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -13,11 +17,15 @@ module GOVUKDesignSystemFormBuilder
13
17
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
14
18
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
15
19
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
20
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
16
21
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
17
22
  # @option caption text [String] the caption text
18
23
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
19
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
20
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
24
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
25
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
26
+ # @param form_group [Hash] configures the form group
27
+ # @option form_group classes [Array,String] sets the form group's classes
28
+ # @option form_group kwargs [Hash] additional attributes added to the form group
21
29
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
22
30
  # @return [ActiveSupport::SafeBuffer] HTML output
23
31
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -26,7 +34,7 @@ module GOVUKDesignSystemFormBuilder
26
34
  # @example A required full name field with a placeholder
27
35
  # = f.govuk_text_field :name,
28
36
  # label: { text: 'Full name' },
29
- # hint_text: 'It says it on your birth certificate',
37
+ # hint: { text: 'It says it on your birth certificate' },
30
38
  # required: true,
31
39
  # placeholder: 'Ralph Wiggum'
32
40
  #
@@ -41,14 +49,17 @@ module GOVUKDesignSystemFormBuilder
41
49
  # = f.govuk_text_field :callsign,
42
50
  # label: -> { tag.h3('Call-sign') }
43
51
  #
44
- def govuk_text_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, form_group_classes: nil, **args, &block)
45
- Elements::Inputs::Text.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, form_group_classes: form_group_classes, **args, &block).html
52
+ def govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **kwargs, &block)
53
+ Elements::Inputs::Text.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **kwargs, &block).html
46
54
  end
47
55
 
48
56
  # Generates a input of type +tel+
49
57
  #
50
58
  # @param attribute_name [Symbol] The name of the attribute
51
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
59
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
60
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
61
+ # @option hint text [String] the hint text
62
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
52
63
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
53
64
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
54
65
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -56,11 +67,15 @@ module GOVUKDesignSystemFormBuilder
56
67
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
57
68
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
58
69
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
70
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
59
71
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
60
72
  # @option caption text [String] the caption text
61
73
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
62
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
63
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
74
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
75
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
76
+ # @param form_group [Hash] configures the form group
77
+ # @option form_group classes [Array,String] sets the form group's classes
78
+ # @option form_group kwargs [Hash] additional attributes added to the form group
64
79
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
65
80
  # @return [ActiveSupport::SafeBuffer] HTML output
66
81
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -70,7 +85,7 @@ module GOVUKDesignSystemFormBuilder
70
85
  # @example A required phone number field with a placeholder
71
86
  # = f.govuk_phone_field :phone_number,
72
87
  # label: { text: 'UK telephone number' },
73
- # hint_text: 'Include the dialling code',
88
+ # hint: { text: 'Include the dialling code' },
74
89
  # required: true,
75
90
  # placeholder: '0123 456 789'
76
91
  #
@@ -85,14 +100,17 @@ module GOVUKDesignSystemFormBuilder
85
100
  # = f.govuk_phone_field :work_number,
86
101
  # label: -> { tag.h3('Work number') }
87
102
  #
88
- def govuk_phone_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, form_group_classes: nil, **args, &block)
89
- Elements::Inputs::Phone.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, form_group_classes: form_group_classes, **args, &block).html
103
+ def govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **kwargs, &block)
104
+ Elements::Inputs::Phone.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **kwargs, &block).html
90
105
  end
91
106
 
92
107
  # Generates a input of type +email+
93
108
  #
94
109
  # @param attribute_name [Symbol] The name of the attribute
95
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
110
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
111
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
112
+ # @option hint text [String] the hint text
113
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
96
114
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
97
115
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
98
116
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -100,11 +118,15 @@ module GOVUKDesignSystemFormBuilder
100
118
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
101
119
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
102
120
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
121
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
103
122
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
104
123
  # @option caption text [String] the caption text
105
124
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
106
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
107
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
125
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
126
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
127
+ # @param form_group [Hash] configures the form group
128
+ # @option form_group classes [Array,String] sets the form group's classes
129
+ # @option form_group kwargs [Hash] additional attributes added to the form group
108
130
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
109
131
  # @return [ActiveSupport::SafeBuffer] HTML output
110
132
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -127,14 +149,17 @@ module GOVUKDesignSystemFormBuilder
127
149
  # = f.govuk_email_field :personal_email,
128
150
  # label: -> { tag.h3('Personal email address') }
129
151
  #
130
- def govuk_email_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, form_group_classes: nil, **args, &block)
131
- Elements::Inputs::Email.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, form_group_classes: form_group_classes, **args, &block).html
152
+ def govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **kwargs, &block)
153
+ Elements::Inputs::Email.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **kwargs, &block).html
132
154
  end
133
155
 
134
156
  # Generates a input of type +password+
135
157
  #
136
158
  # @param attribute_name [Symbol] The name of the attribute
137
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
159
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
160
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
161
+ # @option hint text [String] the hint text
162
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
138
163
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
139
164
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
140
165
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -142,11 +167,15 @@ module GOVUKDesignSystemFormBuilder
142
167
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
143
168
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
144
169
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
170
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
145
171
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
146
172
  # @option caption text [String] the caption text
147
173
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
148
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
149
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
174
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
175
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
176
+ # @param form_group [Hash] configures the form group
177
+ # @option form_group classes [Array,String] sets the form group's classes
178
+ # @option form_group kwargs [Hash] additional attributes added to the form group
150
179
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
151
180
  # @return [ActiveSupport::SafeBuffer] HTML output
152
181
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -168,14 +197,17 @@ module GOVUKDesignSystemFormBuilder
168
197
  # = f.govuk_password_field :passcode,
169
198
  # label: -> { tag.h3('What is your secret pass code?') }
170
199
  #
171
- def govuk_password_field(attribute_name, hint_text: nil, label: {}, width: nil, form_group_classes: nil, caption: {}, **args, &block)
172
- Elements::Inputs::Password.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, form_group_classes: form_group_classes, **args, &block).html
200
+ def govuk_password_field(attribute_name, hint: {}, label: {}, width: nil, form_group: {}, caption: {}, **kwargs, &block)
201
+ Elements::Inputs::Password.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **kwargs, &block).html
173
202
  end
174
203
 
175
204
  # Generates a input of type +url+
176
205
  #
177
206
  # @param attribute_name [Symbol] The name of the attribute
178
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
207
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
208
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
209
+ # @option hint text [String] the hint text
210
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
179
211
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
180
212
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
181
213
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -183,11 +215,15 @@ module GOVUKDesignSystemFormBuilder
183
215
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
184
216
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
185
217
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
218
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
186
219
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
187
220
  # @option caption text [String] the caption text
188
221
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
189
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
190
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
222
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
223
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
224
+ # @param form_group [Hash] configures the form group
225
+ # @option form_group classes [Array,String] sets the form group's classes
226
+ # @option form_group kwargs [Hash] additional attributes added to the form group
191
227
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
192
228
  # @return [ActiveSupport::SafeBuffer] HTML output
193
229
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -210,14 +246,17 @@ module GOVUKDesignSystemFormBuilder
210
246
  # = f.govuk_url_field :work_website,
211
247
  # label: -> { tag.h3("Enter your company's website") }
212
248
  #
213
- def govuk_url_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, form_group_classes: nil, **args, &block)
214
- Elements::Inputs::URL.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, form_group_classes: form_group_classes, **args, &block).html
249
+ def govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **kwargs, &block)
250
+ Elements::Inputs::URL.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **kwargs, &block).html
215
251
  end
216
252
 
217
253
  # Generates a input of type +number+
218
254
  #
219
255
  # @param attribute_name [Symbol] The name of the attribute
220
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
256
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
257
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
258
+ # @option hint text [String] the hint text
259
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
221
260
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
222
261
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
223
262
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -225,11 +264,15 @@ module GOVUKDesignSystemFormBuilder
225
264
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
226
265
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
227
266
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
267
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
228
268
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
229
269
  # @option caption text [String] the caption text
230
270
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
231
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
232
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
271
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
272
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
273
+ # @param form_group [Hash] configures the form group
274
+ # @option form_group classes [Array,String] sets the form group's classes
275
+ # @option form_group kwargs [Hash] additional attributes added to the form group
233
276
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
234
277
  # @return [ActiveSupport::SafeBuffer] HTML output
235
278
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -255,8 +298,8 @@ module GOVUKDesignSystemFormBuilder
255
298
  # = f.govuk_url_field :personal_best_over_100m,
256
299
  # label: -> { tag.h3("How many seconds does it take you to run 100m?") }
257
300
  #
258
- def govuk_number_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, form_group_classes: nil, **args, &block)
259
- Elements::Inputs::Number.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, form_group_classes: form_group_classes, **args, &block).html
301
+ def govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **kwargs, &block)
302
+ Elements::Inputs::Number.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **kwargs, &block).html
260
303
  end
261
304
 
262
305
  # Generates a +textarea+ element with a label, optional hint. Also offers
@@ -264,21 +307,28 @@ module GOVUKDesignSystemFormBuilder
264
307
  # automatically
265
308
  #
266
309
  # @param attribute_name [Symbol] The name of the attribute
267
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
310
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
311
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
312
+ # @option hint text [String] the hint text
313
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
268
314
  # @param label [Hash,Proc] configures or sets the associated label content
269
315
  # @option label text [String] the label text
270
316
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
271
317
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
272
318
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
319
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
273
320
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
274
321
  # @option caption text [String] the caption text
275
322
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
323
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
276
324
  # @param max_words [Integer] adds the GOV.UK max word count
277
325
  # @param max_chars [Integer] adds the GOV.UK max characters count
278
326
  # @param threshold [Integer] only show the +max_words+ and +max_chars+ warnings once a threshold (percentage) is reached
279
327
  # @param rows [Integer] sets the initial number of rows
280
- # @option args [Hash] args additional arguments are applied as attributes to the +textarea+ element
281
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
328
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +textarea+ element
329
+ # @param form_group [Hash] configures the form group
330
+ # @option form_group classes [Array,String] sets the form group's classes
331
+ # @option form_group kwargs [Hash] additional attributes added to the form group
282
332
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
283
333
  # @return [ActiveSupport::SafeBuffer] HTML output
284
334
  # @see https://design-system.service.gov.uk/components/textarea/ GOV.UK text area component
@@ -304,8 +354,8 @@ module GOVUKDesignSystemFormBuilder
304
354
  # = f.govuk_text_area :instructions,
305
355
  # label: -> { tag.h3("How do you set it up?") }
306
356
  #
307
- def govuk_text_area(attribute_name, hint_text: nil, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group_classes: nil, **args, &block)
308
- Elements::TextArea.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, max_words: max_words, max_chars: max_chars, rows: rows, threshold: threshold, form_group_classes: form_group_classes, **args, &block).html
357
+ def govuk_text_area(attribute_name, hint: {}, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group: {}, **kwargs, &block)
358
+ Elements::TextArea.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, max_words: max_words, max_chars: max_chars, rows: rows, threshold: threshold, form_group: form_group, **kwargs, &block).html
309
359
  end
310
360
 
311
361
  # Generates a +select+ element containing +option+ for each member in the provided collection
@@ -314,14 +364,20 @@ module GOVUKDesignSystemFormBuilder
314
364
  # @param collection [Enumerable<Object>] Options to be added to the +select+ element
315
365
  # @param value_method [Symbol] The method called against each member of the collection to provide the value
316
366
  # @param text_method [Symbol] The method called against each member of the collection to provide the text
317
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
367
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
368
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
369
+ # @option hint text [String] the hint text
370
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
318
371
  # @option label text [String] the label text
319
372
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
320
373
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
321
374
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
375
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
322
376
  # @param options [Hash] Options hash passed through to Rails' +collection_select+ helper
323
377
  # @param html_options [Hash] HTML Options hash passed through to Rails' +collection_select+ helper
324
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
378
+ # @param form_group [Hash] configures the form group
379
+ # @option form_group classes [Array,String] sets the form group's classes
380
+ # @option form_group kwargs [Hash] additional attributes added to the form group
325
381
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
326
382
  # @see https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select Rails collection_select (called by govuk_collection_select)
327
383
  # @return [ActiveSupport::SafeBuffer] HTML output
@@ -331,7 +387,7 @@ module GOVUKDesignSystemFormBuilder
331
387
  # @grades,
332
388
  # :id,
333
389
  # :name,
334
- # hint_text: "If you took the test more than once enter your highest grade"
390
+ # hint: { text: "If you took the test more than once enter your highest grade" }
335
391
  #
336
392
  # @example A select box with injected content
337
393
  # = f.govuk_collection_select(:favourite_colour, @colours, :id, :name) do
@@ -343,7 +399,7 @@ module GOVUKDesignSystemFormBuilder
343
399
  # = f.govuk_collection_select(:team, @teams, :id, :name) do
344
400
  # label: -> { tag.h3("Which team did you represent?") }
345
401
  #
346
- def govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, html_options: {}, hint_text: nil, label: {}, caption: {}, form_group_classes: nil, &block)
402
+ def govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, html_options: {}, hint: {}, label: {}, caption: {}, form_group: {}, &block)
347
403
  Elements::Select.new(
348
404
  self,
349
405
  object_name,
@@ -351,12 +407,12 @@ module GOVUKDesignSystemFormBuilder
351
407
  collection,
352
408
  value_method: value_method,
353
409
  text_method: text_method,
354
- hint_text: hint_text,
410
+ hint: hint,
355
411
  label: label,
356
412
  caption: caption,
357
413
  options: options,
358
414
  html_options: html_options,
359
- form_group_classes: form_group_classes,
415
+ form_group: form_group,
360
416
  &block
361
417
  ).html
362
418
  end
@@ -380,8 +436,11 @@ module GOVUKDesignSystemFormBuilder
380
436
  # @param hint_method [Symbol, Proc, nil] The method called against each member of the collection to provide the hint text.
381
437
  # When a +Proc+ is provided it must take a single argument that is a single member of the collection.
382
438
  # When a +nil+ value is provided the hint text will be retrieved from the locale. This is the default and param can be omitted.
383
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
384
- # @param legend [Hash,Proc] options for configuring the legend
439
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
440
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
441
+ # @option hint text [String] the hint text
442
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
443
+ # @param legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
385
444
  # @param inline [Boolean] controls whether the radio buttons are displayed inline or not
386
445
  # @param small [Boolean] controls whether small radio buttons are used instead of regular-sized ones
387
446
  # @param bold_labels [Boolean] controls whether the radio button labels are bold
@@ -390,9 +449,11 @@ module GOVUKDesignSystemFormBuilder
390
449
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
391
450
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
392
451
  # @option legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
452
+ # @option legend kwargs [Hash] additional arguments are applied as attributes on the +legend+ element
393
453
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
394
454
  # @option caption text [String] the caption text
395
455
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
456
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
396
457
  # @return [ActiveSupport::SafeBuffer] HTML output
397
458
  #
398
459
  # @example A collection of radio buttons for favourite colours, labels capitalised via a proc
@@ -408,7 +469,7 @@ module GOVUKDesignSystemFormBuilder
408
469
  # ->(option) { option.name.upcase },
409
470
  # :description,
410
471
  # legend: { text: 'Pick your favourite colour', size: 'm' },
411
- # hint_text: 'If you cannot find the exact match choose something close',
472
+ # hint: { text: 'If you cannot find the exact match choose something close' },
412
473
  # inline: false
413
474
  #
414
475
  # @example A collection of radio buttons for grades with injected content
@@ -427,7 +488,7 @@ module GOVUKDesignSystemFormBuilder
427
488
  # :name,
428
489
  # legend: -> { tag.h3('Which category do you belong to?') }
429
490
  #
430
- def govuk_collection_radio_buttons(attribute_name, collection, value_method, text_method, hint_method = nil, hint_text: nil, legend: {}, caption: {}, inline: false, small: false, bold_labels: false, classes: nil, form_group_classes: nil, &block)
491
+ def govuk_collection_radio_buttons(attribute_name, collection, value_method, text_method = nil, hint_method = nil, hint: {}, legend: {}, caption: {}, inline: false, small: false, bold_labels: false, classes: nil, form_group: {}, &block)
431
492
  Elements::Radios::Collection.new(
432
493
  self,
433
494
  object_name,
@@ -436,14 +497,14 @@ module GOVUKDesignSystemFormBuilder
436
497
  value_method: value_method,
437
498
  text_method: text_method,
438
499
  hint_method: hint_method,
439
- hint_text: hint_text,
500
+ hint: hint,
440
501
  legend: legend,
441
502
  caption: caption,
442
503
  inline: inline,
443
504
  small: small,
444
505
  bold_labels: bold_labels,
445
506
  classes: classes,
446
- form_group_classes: form_group_classes,
507
+ form_group: form_group,
447
508
  &block
448
509
  ).html
449
510
  end
@@ -456,18 +517,25 @@ module GOVUKDesignSystemFormBuilder
456
517
  # is set to +link_errors: true+
457
518
  #
458
519
  # @param attribute_name [Symbol] The name of the attribute
459
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
460
- # @param legend [Hash,Proc] options for configuring the legend
520
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
521
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
522
+ # @option hint text [String] the hint text
523
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
524
+ # @param legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
461
525
  # @param inline [Boolean] controls whether the radio buttons are displayed inline or not
462
526
  # @param small [Boolean] controls whether small radio buttons are used instead of regular-sized ones
463
527
  # @option legend text [String] the fieldset legend's text content
464
528
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
465
529
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
466
530
  # @option legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
531
+ # @option legend kwargs [Hash] additional arguments are applied as attributes on the +legend+ element
467
532
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
468
533
  # @option caption text [String] the caption text
469
534
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
470
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
535
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
536
+ # @param form_group [Hash] configures the form group
537
+ # @option form_group classes [Array,String] sets the form group's classes
538
+ # @option form_group kwargs [Hash] additional attributes added to the form group
471
539
  # @param block [Block] a block of HTML that will be used to populate the fieldset
472
540
  # @param classes [Array,String] Classes to add to the radio button container.
473
541
  # @see https://design-system.service.gov.uk/components/radios/ GOV.UK Radios
@@ -491,19 +559,24 @@ module GOVUKDesignSystemFormBuilder
491
559
  # = f.govuk_radio_button :burger_id, :regular, label: { text: 'Hamburger' }, link_errors: true
492
560
  # = f.govuk_radio_button :burger_id, :cheese, label: { text: 'Cheeseburger' }
493
561
  #
494
- def govuk_radio_buttons_fieldset(attribute_name, hint_text: nil, legend: {}, caption: {}, inline: false, small: false, classes: nil, form_group_classes: nil, &block)
495
- Containers::RadioButtonsFieldset.new(self, object_name, attribute_name, hint_text: hint_text, legend: legend, caption: caption, inline: inline, small: small, classes: classes, form_group_classes: form_group_classes, &block).html
562
+ def govuk_radio_buttons_fieldset(attribute_name, hint: {}, legend: {}, caption: {}, inline: false, small: false, classes: nil, form_group: {}, &block)
563
+ Containers::RadioButtonsFieldset.new(self, object_name, attribute_name, hint: hint, legend: legend, caption: caption, inline: inline, small: small, classes: classes, form_group: form_group, &block).html
496
564
  end
497
565
 
498
566
  # Generates a radio button
499
567
  #
500
568
  # @note This should only be used from within a {#govuk_radio_buttons_fieldset}
501
569
  # @param attribute_name [Symbol] The name of the attribute
502
- # @param hint_text [String] the contents of the hint
503
- # @option legend text [String] the fieldset legend's text content
504
- # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
505
- # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
506
- # @option legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
570
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
571
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
572
+ # @option hint text [String] the hint text
573
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
574
+ # @param label [Hash,Proc] configures or sets the associated label content
575
+ # @option label text [String] the label text
576
+ # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
577
+ # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
578
+ # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
579
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
507
580
  # @see https://design-system.service.gov.uk/components/radios/ GOV.UK Radios
508
581
  # @see https://design-system.service.gov.uk/styles/typography/#headings-with-captions Headings with captions
509
582
  # @param block [Block] Any supplied HTML will be wrapped in a conditional
@@ -517,8 +590,8 @@ module GOVUKDesignSystemFormBuilder
517
590
  # = f.govuk_radio_buttons_fieldset :favourite_colour do
518
591
  # = f.govuk_radio_button :favourite_colour, :red, label: { text: 'Red' }
519
592
  #
520
- def govuk_radio_button(attribute_name, value, hint_text: nil, label: {}, link_errors: false, &block)
521
- Elements::Radios::FieldsetRadioButton.new(self, object_name, attribute_name, value, hint_text: hint_text, label: label, link_errors: link_errors, &block).html
593
+ def govuk_radio_button(attribute_name, value, hint: {}, label: {}, link_errors: false, &block)
594
+ Elements::Radios::FieldsetRadioButton.new(self, object_name, attribute_name, value, hint: hint, label: label, link_errors: link_errors, &block).html
522
595
  end
523
596
 
524
597
  # Inserts a text divider into a list of radio buttons
@@ -541,10 +614,13 @@ module GOVUKDesignSystemFormBuilder
541
614
  # @param text_method [Symbol] The method called against each member of the collection to provide the label text
542
615
  # @param hint_method [Symbol, Proc] The method called against each member of the collection to provide the hint text.
543
616
  # When a +Proc+ is provided it must take a single argument that is a single member of the collection
544
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
617
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
618
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
619
+ # @option hint text [String] the hint text
620
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
545
621
  # @param small [Boolean] controls whether small check boxes are used instead of regular-sized ones
546
622
  # @param classes [Array,String] Classes to add to the checkbox container.
547
- # @param legend [Hash,Proc] options for configuring the legend
623
+ # @param legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
548
624
  # @option legend text [String] the fieldset legend's text content
549
625
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
550
626
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
@@ -552,7 +628,10 @@ module GOVUKDesignSystemFormBuilder
552
628
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
553
629
  # @option caption text [String] the caption text
554
630
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
555
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
631
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
632
+ # @param form_group [Hash] configures the form group
633
+ # @option form_group classes [Array,String] sets the form group's classes
634
+ # @option form_group kwargs [Hash] additional attributes added to the form group
556
635
  # @param block [Block] any HTML passed in will be injected into the fieldset, after the hint and before the checkboxes
557
636
  # @return [ActiveSupport::SafeBuffer] HTML output
558
637
  #
@@ -569,7 +648,7 @@ module GOVUKDesignSystemFormBuilder
569
648
  # :name,
570
649
  # :description,
571
650
  # legend: { text: 'What do you want in your sandwich?', size: 'm' },
572
- # hint_text: "If it isn't listed here, tough luck",
651
+ # hint: { text: "If it isn't listed here, tough luck" },
573
652
  # inline: false,
574
653
  # classes: 'app-overflow-scroll',
575
654
  #
@@ -589,7 +668,7 @@ module GOVUKDesignSystemFormBuilder
589
668
  # :name,
590
669
  # legend: -> { tag.h3('What kind of sandwich do you want?') }
591
670
  #
592
- def govuk_collection_check_boxes(attribute_name, collection, value_method, text_method, hint_method = nil, hint_text: nil, legend: {}, caption: {}, small: false, classes: nil, form_group_classes: nil, &block)
671
+ def govuk_collection_check_boxes(attribute_name, collection, value_method, text_method, hint_method = nil, hint: {}, legend: {}, caption: {}, small: false, classes: nil, form_group: {}, &block)
593
672
  Elements::CheckBoxes::Collection.new(
594
673
  self,
595
674
  object_name,
@@ -598,12 +677,12 @@ module GOVUKDesignSystemFormBuilder
598
677
  value_method: value_method,
599
678
  text_method: text_method,
600
679
  hint_method: hint_method,
601
- hint_text: hint_text,
680
+ hint: hint,
602
681
  legend: legend,
603
682
  caption: caption,
604
683
  small: small,
605
684
  classes: classes,
606
- form_group_classes: form_group_classes,
685
+ form_group: form_group,
607
686
  &block
608
687
  ).html
609
688
  end
@@ -614,18 +693,25 @@ module GOVUKDesignSystemFormBuilder
614
693
  # is set to +link_errors: true+
615
694
  #
616
695
  # @param attribute_name [Symbol] The name of the attribute
617
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
696
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
697
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
698
+ # @option hint text [String] the hint text
699
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
618
700
  # @param small [Boolean] controls whether small check boxes are used instead of regular-sized ones
619
- # @param legend [Hash,Proc] options for configuring the legend
701
+ # @param legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
620
702
  # @option legend text [String] the fieldset legend's text content
621
703
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
622
704
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
623
705
  # @option legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
706
+ # @option legend kwargs [Hash] additional arguments are applied as attributes on the +legend+ element
624
707
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
625
708
  # @option caption text [String] the caption text
626
709
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
710
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
627
711
  # @param classes [Array,String] Classes to add to the checkbox container.
628
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
712
+ # @param form_group [Hash] configures the form group
713
+ # @option form_group classes [Array,String] sets the form group's classes
714
+ # @option form_group kwargs [Hash] additional attributes added to the form group
629
715
  # @param block [Block] a block of HTML that will be used to populate the fieldset
630
716
  # @return [ActiveSupport::SafeBuffer] HTML output
631
717
  #
@@ -639,17 +725,17 @@ module GOVUKDesignSystemFormBuilder
639
725
  # = f.govuk_check_box :desired_filling, :lemonade, label: { text: 'Lemonade' }, link_errors: true
640
726
  # = f.govuk_check_box :desired_filling, :fizzy_orange, label: { text: 'Fizzy orange' }
641
727
  #
642
- def govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint_text: {}, small: false, classes: nil, form_group_classes: nil, &block)
728
+ def govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint: {}, small: false, classes: nil, form_group: {}, &block)
643
729
  Containers::CheckBoxesFieldset.new(
644
730
  self,
645
731
  object_name,
646
732
  attribute_name,
647
- hint_text: hint_text,
733
+ hint: hint,
648
734
  legend: legend,
649
735
  caption: caption,
650
736
  small: small,
651
737
  classes: classes,
652
- form_group_classes: form_group_classes,
738
+ form_group: form_group,
653
739
  &block
654
740
  ).html
655
741
  end
@@ -658,12 +744,16 @@ module GOVUKDesignSystemFormBuilder
658
744
  #
659
745
  # @param attribute_name [Symbol] The name of the attribute
660
746
  # @param value [Boolean,String,Symbol,Integer] The value of the checkbox when it is checked
661
- # @param hint_text [String] the contents of the hint
747
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
748
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
749
+ # @option hint text [String] the hint text
750
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
662
751
  # @param link_errors [Boolean] controls whether this radio button should be linked to from {#govuk_error_summary}
663
752
  # @option label text [String] the label text
664
753
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
665
754
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
666
755
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
756
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
667
757
  # @param multiple [Boolean] controls whether the check box is part of a collection or represents a single attribute
668
758
  # @param block [Block] any HTML passed in will form the contents of the fieldset
669
759
  # @return [ActiveSupport::SafeBuffer] HTML output
@@ -674,15 +764,15 @@ module GOVUKDesignSystemFormBuilder
674
764
  # multiple: false,
675
765
  # link_errors: true,
676
766
  # label: { text: 'Do you agree with our terms and conditions?' },
677
- # hint_text: 'You will not be able to proceed unless you do'
767
+ # hint: { text: 'You will not be able to proceed unless you do' }
678
768
  #
679
- def govuk_check_box(attribute_name, value, hint_text: nil, label: {}, link_errors: false, multiple: true, &block)
769
+ def govuk_check_box(attribute_name, value, hint: {}, label: {}, link_errors: false, multiple: true, &block)
680
770
  Elements::CheckBoxes::FieldsetCheckBox.new(
681
771
  self,
682
772
  object_name,
683
773
  attribute_name,
684
774
  value,
685
- hint_text: hint_text,
775
+ hint: hint,
686
776
  label: label,
687
777
  link_errors: link_errors,
688
778
  multiple: multiple,
@@ -726,17 +816,24 @@ module GOVUKDesignSystemFormBuilder
726
816
  # of {https://bugs.ruby-lang.org/issues/5988 this} bug, so incorrect dates like +2019-09-31+ will
727
817
  # be 'rounded' up to +2019-10-01+.
728
818
  # @param attribute_name [Symbol] The name of the attribute
729
- # @param hint_text [String] the contents of the hint
730
- # @param legend [Hash,Proc] options for configuring the legend
819
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
820
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
821
+ # @option hint text [String] the hint text
822
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
823
+ # @param legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
731
824
  # @option legend text [String] the fieldset legend's text content
732
825
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
733
826
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
734
827
  # @option legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
828
+ # @option legend kwargs [Hash] additional arguments are applied as attributes on the +legend+ element
735
829
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
736
830
  # @option caption text [String] the caption text
737
831
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
832
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
738
833
  # @param omit_day [Boolean] do not render a day input, only capture month and year
739
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
834
+ # @param form_group [Hash] configures the form group
835
+ # @option form_group classes [Array,String] sets the form group's classes
836
+ # @option form_group kwargs [Hash] additional attributes added to the form group
740
837
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input group
741
838
  # @param date_of_birth [Boolean] if +true+ {https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#Values birth date auto completion attributes}
742
839
  # will be added to the inputs
@@ -748,7 +845,7 @@ module GOVUKDesignSystemFormBuilder
748
845
  # @example A regular date input with a legend, hint and injected content
749
846
  # = f.govuk_date_field :starts_on,
750
847
  # legend: { 'When does your event start?' },
751
- # hint_text: 'Leave this field blank if you don't know exactly' } do
848
+ # hint: { text: 'Leave this field blank if you don't know exactly' } do
752
849
  #
753
850
  # p.govuk-inset-text
754
851
  # | If you don't fill this in you won't be eligable for a refund
@@ -756,8 +853,8 @@ module GOVUKDesignSystemFormBuilder
756
853
  # @example A date input with legend supplied as a proc
757
854
  # = f.govuk_date_field :finishes_on,
758
855
  # legend: -> { tag.h3('Which category do you belong to?') }
759
- def govuk_date_field(attribute_name, hint_text: nil, legend: {}, caption: {}, date_of_birth: false, omit_day: false, form_group_classes: nil, &block)
760
- Elements::Date.new(self, object_name, attribute_name, hint_text: hint_text, legend: legend, caption: caption, date_of_birth: date_of_birth, omit_day: omit_day, form_group_classes: form_group_classes, &block).html
856
+ def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, form_group: {}, &block)
857
+ Elements::Date.new(self, object_name, attribute_name, hint: hint, legend: legend, caption: caption, date_of_birth: date_of_birth, omit_day: omit_day, form_group: form_group, &block).html
761
858
  end
762
859
 
763
860
  # Generates a summary of errors in the form, each linking to the corresponding
@@ -775,15 +872,17 @@ module GOVUKDesignSystemFormBuilder
775
872
 
776
873
  # Generates a fieldset containing the contents of the block
777
874
  #
778
- # @param legend [Hash,Proc] options for configuring the legend
875
+ # @param legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
779
876
  # @param described_by [Array<String>] the ids of the elements that describe this fieldset, usually hints and errors
780
877
  # @option legend text [String] the fieldset legend's text content
781
878
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
782
879
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
783
880
  # @option legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
881
+ # @option legend kwargs [Hash] additional arguments are applied as attributes on the +legend+ element
784
882
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
785
883
  # @option caption text [String] the caption text
786
884
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
885
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
787
886
  #
788
887
  # @example A fieldset containing address fields
789
888
  # = f.govuk_fieldset legend: { text: 'Address' }
@@ -810,12 +909,19 @@ module GOVUKDesignSystemFormBuilder
810
909
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
811
910
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
812
911
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
912
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
813
913
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
814
914
  # @option caption text [String] the caption text
815
915
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
816
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
817
- # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
818
- # @param form_group_classes [Array,String] Classes to add to the surrounding +form-group+
916
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
917
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
918
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
919
+ # @option hint text [String] the hint text
920
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
921
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
922
+ # @param form_group [Hash] configures the form group
923
+ # @option form_group classes [Array,String] sets the form group's classes
924
+ # @option form_group kwargs [Hash] additional attributes added to the form group
819
925
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
820
926
  #
821
927
  # @example A photo upload field with file type specifier and injected content
@@ -834,8 +940,8 @@ module GOVUKDesignSystemFormBuilder
834
940
  # @note Remember to set +multipart: true+ when creating a form with file
835
941
  # uploads, {https://guides.rubyonrails.org/form_helpers.html#uploading-files see
836
942
  # the Rails documentation} for more information
837
- def govuk_file_field(attribute_name, label: {}, caption: {}, hint_text: nil, form_group_classes: nil, **args, &block)
838
- Elements::File.new(self, object_name, attribute_name, label: label, caption: caption, hint_text: hint_text, form_group_classes: form_group_classes, **args, &block).html
943
+ def govuk_file_field(attribute_name, label: {}, caption: {}, hint: {}, form_group: {}, **kwargs, &block)
944
+ Elements::File.new(self, object_name, attribute_name, label: label, caption: caption, hint: hint, form_group: form_group, **kwargs, &block).html
839
945
  end
840
946
  end
841
947
  end