govuk_design_system_formbuilder 1.2.3 → 2.0.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) 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 +155 -60
  6. data/lib/govuk_design_system_formbuilder/containers/character_count.rb +8 -7
  7. data/lib/govuk_design_system_formbuilder/containers/check_boxes.rb +18 -10
  8. data/lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb +13 -4
  9. data/lib/govuk_design_system_formbuilder/containers/fieldset.rb +15 -55
  10. data/lib/govuk_design_system_formbuilder/containers/form_group.rb +19 -10
  11. data/lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb +13 -4
  12. data/lib/govuk_design_system_formbuilder/containers/radios.rb +22 -11
  13. data/lib/govuk_design_system_formbuilder/containers/supplemental.rb +3 -3
  14. data/lib/govuk_design_system_formbuilder/elements/caption.rb +6 -4
  15. data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb +21 -12
  16. data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection_check_box.rb +9 -7
  17. data/lib/govuk_design_system_formbuilder/elements/check_boxes/fieldset_check_box.rb +24 -16
  18. data/lib/govuk_design_system_formbuilder/elements/date.rb +47 -40
  19. data/lib/govuk_design_system_formbuilder/elements/error_message.rb +4 -4
  20. data/lib/govuk_design_system_formbuilder/elements/error_summary.rb +15 -15
  21. data/lib/govuk_design_system_formbuilder/elements/file.rb +8 -7
  22. data/lib/govuk_design_system_formbuilder/elements/hint.rb +43 -16
  23. data/lib/govuk_design_system_formbuilder/elements/inputs/email.rb +2 -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 +35 -27
  30. data/lib/govuk_design_system_formbuilder/elements/legend.rb +79 -0
  31. data/lib/govuk_design_system_formbuilder/elements/radios/collection.rb +23 -14
  32. data/lib/govuk_design_system_formbuilder/elements/radios/collection_radio_button.rb +24 -8
  33. data/lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb +19 -7
  34. data/lib/govuk_design_system_formbuilder/elements/select.rb +24 -19
  35. data/lib/govuk_design_system_formbuilder/elements/submit.rb +11 -6
  36. data/lib/govuk_design_system_formbuilder/elements/text_area.rb +31 -25
  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 +9 -8
  41. data/lib/govuk_design_system_formbuilder/traits/label.rb +2 -2
  42. data/lib/govuk_design_system_formbuilder/version.rb +1 -1
  43. metadata +11 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b04804863d4a75157988de721c6fda535eb35df444b8a99a8830b7b9758f8e03
4
- data.tar.gz: 162d14ae3760447cf707bc89195daa2a66ca104265258d751b1082325ed56aa8
3
+ metadata.gz: 52cc4abc62b3ac208e8fe2befb527b6deda60868d2094a3172d907bc0ce82654
4
+ data.tar.gz: fb0c810a65f025e226fe4dc0cee0c5b42b3b7baa499b032d6f88d4ec2fac9d54
5
5
  SHA512:
6
- metadata.gz: 71814ceeaf1bb257102a0b4f3e04675bf44aa10a3b85837420d30295bf1b77e9f63c6498dc6d0a8560c5cfb7abcecd7ec057d7ce73a7b2f0f682849eae71a7ba
7
- data.tar.gz: 16d9e596f3a56b25a5413aed0b996d1965cd0be1a2fb6653217cea9b41b1334f9918a75f71ea0f6ba51844b617bd0a2a3a0686c4c8fb34f05b999afce50f8f67
6
+ metadata.gz: 996a9f979a4eab0a16499f81cf39fdcfbd0c641dd5d2944c52be697cd6f1f8870b75c6fd4b498d3769265fa39168f7baefe36bb53255bc50a9bfcb82f06bd641
7
+ data.tar.gz: ef2f8f3eaba7ea21b2ae18a7a4ba8c181981164f36917d082ff5f2545896df17c6b27c9acab09621d3e5453013d9e5747e5f838b54bc2f2e68aed585980190d9
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 args [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
@@ -17,6 +21,9 @@ module GOVUKDesignSystemFormBuilder
17
21
  # @option caption text [String] the caption text
18
22
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
19
23
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
24
+ # @param form_group [Hash] configures the form group
25
+ # @option form_group classes [Array,String] sets the form group's classes
26
+ # @option form_group args [Hash] additional attributes added to the form group
20
27
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
21
28
  # @return [ActiveSupport::SafeBuffer] HTML output
22
29
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -25,7 +32,7 @@ module GOVUKDesignSystemFormBuilder
25
32
  # @example A required full name field with a placeholder
26
33
  # = f.govuk_text_field :name,
27
34
  # label: { text: 'Full name' },
28
- # hint_text: 'It says it on your birth certificate',
35
+ # hint: { text: 'It says it on your birth certificate' },
29
36
  # required: true,
30
37
  # placeholder: 'Ralph Wiggum'
31
38
  #
@@ -40,14 +47,17 @@ module GOVUKDesignSystemFormBuilder
40
47
  # = f.govuk_text_field :callsign,
41
48
  # label: -> { tag.h3('Call-sign') }
42
49
  #
43
- def govuk_text_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, **args, &block)
44
- Elements::Inputs::Text.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, **args, &block).html
50
+ def govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **args, &block)
51
+ Elements::Inputs::Text.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **args, &block).html
45
52
  end
46
53
 
47
54
  # Generates a input of type +tel+
48
55
  #
49
56
  # @param attribute_name [Symbol] The name of the attribute
50
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
57
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
58
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
59
+ # @option hint text [String] the hint text
60
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
51
61
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
52
62
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
53
63
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -59,6 +69,9 @@ module GOVUKDesignSystemFormBuilder
59
69
  # @option caption text [String] the caption text
60
70
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
61
71
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
72
+ # @param form_group [Hash] configures the form group
73
+ # @option form_group classes [Array,String] sets the form group's classes
74
+ # @option form_group args [Hash] additional attributes added to the form group
62
75
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
63
76
  # @return [ActiveSupport::SafeBuffer] HTML output
64
77
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -68,7 +81,7 @@ module GOVUKDesignSystemFormBuilder
68
81
  # @example A required phone number field with a placeholder
69
82
  # = f.govuk_phone_field :phone_number,
70
83
  # label: { text: 'UK telephone number' },
71
- # hint_text: 'Include the dialling code',
84
+ # hint: { text: 'Include the dialling code' },
72
85
  # required: true,
73
86
  # placeholder: '0123 456 789'
74
87
  #
@@ -83,14 +96,17 @@ module GOVUKDesignSystemFormBuilder
83
96
  # = f.govuk_phone_field :work_number,
84
97
  # label: -> { tag.h3('Work number') }
85
98
  #
86
- def govuk_phone_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, **args, &block)
87
- Elements::Inputs::Phone.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, **args, &block).html
99
+ def govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **args, &block)
100
+ Elements::Inputs::Phone.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **args, &block).html
88
101
  end
89
102
 
90
103
  # Generates a input of type +email+
91
104
  #
92
105
  # @param attribute_name [Symbol] The name of the attribute
93
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
106
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
107
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
108
+ # @option hint text [String] the hint text
109
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
94
110
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
95
111
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
96
112
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -102,6 +118,9 @@ module GOVUKDesignSystemFormBuilder
102
118
  # @option caption text [String] the caption text
103
119
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
104
120
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
121
+ # @param form_group [Hash] configures the form group
122
+ # @option form_group classes [Array,String] sets the form group's classes
123
+ # @option form_group args [Hash] additional attributes added to the form group
105
124
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
106
125
  # @return [ActiveSupport::SafeBuffer] HTML output
107
126
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -124,14 +143,17 @@ module GOVUKDesignSystemFormBuilder
124
143
  # = f.govuk_email_field :personal_email,
125
144
  # label: -> { tag.h3('Personal email address') }
126
145
  #
127
- def govuk_email_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, **args, &block)
128
- Elements::Inputs::Email.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, **args, &block).html
146
+ def govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **args, &block)
147
+ Elements::Inputs::Email.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **args, &block).html
129
148
  end
130
149
 
131
150
  # Generates a input of type +password+
132
151
  #
133
152
  # @param attribute_name [Symbol] The name of the attribute
134
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
153
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
154
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
155
+ # @option hint text [String] the hint text
156
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
135
157
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
136
158
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
137
159
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -143,6 +165,9 @@ module GOVUKDesignSystemFormBuilder
143
165
  # @option caption text [String] the caption text
144
166
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
145
167
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
168
+ # @param form_group [Hash] configures the form group
169
+ # @option form_group classes [Array,String] sets the form group's classes
170
+ # @option form_group args [Hash] additional attributes added to the form group
146
171
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
147
172
  # @return [ActiveSupport::SafeBuffer] HTML output
148
173
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -164,14 +189,17 @@ module GOVUKDesignSystemFormBuilder
164
189
  # = f.govuk_password_field :passcode,
165
190
  # label: -> { tag.h3('What is your secret pass code?') }
166
191
  #
167
- def govuk_password_field(attribute_name, hint_text: nil, label: {}, width: nil, caption: {}, **args, &block)
168
- Elements::Inputs::Password.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, **args, &block).html
192
+ def govuk_password_field(attribute_name, hint: {}, label: {}, width: nil, form_group: {}, caption: {}, **args, &block)
193
+ Elements::Inputs::Password.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **args, &block).html
169
194
  end
170
195
 
171
196
  # Generates a input of type +url+
172
197
  #
173
198
  # @param attribute_name [Symbol] The name of the attribute
174
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
199
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
200
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
201
+ # @option hint text [String] the hint text
202
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
175
203
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
176
204
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
177
205
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -183,6 +211,9 @@ module GOVUKDesignSystemFormBuilder
183
211
  # @option caption text [String] the caption text
184
212
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
185
213
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
214
+ # @param form_group [Hash] configures the form group
215
+ # @option form_group classes [Array,String] sets the form group's classes
216
+ # @option form_group args [Hash] additional attributes added to the form group
186
217
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
187
218
  # @return [ActiveSupport::SafeBuffer] HTML output
188
219
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -205,14 +236,17 @@ module GOVUKDesignSystemFormBuilder
205
236
  # = f.govuk_url_field :work_website,
206
237
  # label: -> { tag.h3("Enter your company's website") }
207
238
  #
208
- def govuk_url_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, **args, &block)
209
- Elements::Inputs::URL.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, **args, &block).html
239
+ def govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **args, &block)
240
+ Elements::Inputs::URL.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **args, &block).html
210
241
  end
211
242
 
212
243
  # Generates a input of type +number+
213
244
  #
214
245
  # @param attribute_name [Symbol] The name of the attribute
215
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
246
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
247
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
248
+ # @option hint text [String] the hint text
249
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
216
250
  # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
217
251
  # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
218
252
  # @param label [Hash,Proc] configures or sets the associated label content
@@ -224,6 +258,9 @@ module GOVUKDesignSystemFormBuilder
224
258
  # @option caption text [String] the caption text
225
259
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
226
260
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
261
+ # @param form_group [Hash] configures the form group
262
+ # @option form_group classes [Array,String] sets the form group's classes
263
+ # @option form_group args [Hash] additional attributes added to the form group
227
264
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
228
265
  # @return [ActiveSupport::SafeBuffer] HTML output
229
266
  # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
@@ -249,8 +286,8 @@ module GOVUKDesignSystemFormBuilder
249
286
  # = f.govuk_url_field :personal_best_over_100m,
250
287
  # label: -> { tag.h3("How many seconds does it take you to run 100m?") }
251
288
  #
252
- def govuk_number_field(attribute_name, hint_text: nil, label: {}, caption: {}, width: nil, **args, &block)
253
- Elements::Inputs::Number.new(self, object_name, attribute_name, hint_text: hint_text, label: label, caption: caption, width: width, **args, &block).html
289
+ def govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, **args, &block)
290
+ Elements::Inputs::Number.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, **args, &block).html
254
291
  end
255
292
 
256
293
  # Generates a +textarea+ element with a label, optional hint. Also offers
@@ -258,7 +295,10 @@ module GOVUKDesignSystemFormBuilder
258
295
  # automatically
259
296
  #
260
297
  # @param attribute_name [Symbol] The name of the attribute
261
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
298
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
299
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
300
+ # @option hint text [String] the hint text
301
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
262
302
  # @param label [Hash,Proc] configures or sets the associated label content
263
303
  # @option label text [String] the label text
264
304
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
@@ -272,6 +312,9 @@ module GOVUKDesignSystemFormBuilder
272
312
  # @param threshold [Integer] only show the +max_words+ and +max_chars+ warnings once a threshold (percentage) is reached
273
313
  # @param rows [Integer] sets the initial number of rows
274
314
  # @option args [Hash] args additional arguments are applied as attributes to the +textarea+ element
315
+ # @param form_group [Hash] configures the form group
316
+ # @option form_group classes [Array,String] sets the form group's classes
317
+ # @option form_group args [Hash] additional attributes added to the form group
275
318
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
276
319
  # @return [ActiveSupport::SafeBuffer] HTML output
277
320
  # @see https://design-system.service.gov.uk/components/textarea/ GOV.UK text area component
@@ -297,8 +340,8 @@ module GOVUKDesignSystemFormBuilder
297
340
  # = f.govuk_text_area :instructions,
298
341
  # label: -> { tag.h3("How do you set it up?") }
299
342
  #
300
- def govuk_text_area(attribute_name, hint_text: nil, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, **args, &block)
301
- 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, **args, &block).html
343
+ def govuk_text_area(attribute_name, hint: {}, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group: {}, **args, &block)
344
+ 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, **args, &block).html
302
345
  end
303
346
 
304
347
  # Generates a +select+ element containing +option+ for each member in the provided collection
@@ -307,12 +350,21 @@ module GOVUKDesignSystemFormBuilder
307
350
  # @param collection [Enumerable<Object>] Options to be added to the +select+ element
308
351
  # @param value_method [Symbol] The method called against each member of the collection to provide the value
309
352
  # @param text_method [Symbol] The method called against each member of the collection to provide the text
310
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
353
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
354
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
355
+ # @option hint text [String] the hint text
356
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
311
357
  # @option label text [String] the label text
312
358
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
313
359
  # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
314
360
  # @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
361
+ # @param options [Hash] Options hash passed through to Rails' +collection_select+ helper
362
+ # @param html_options [Hash] HTML Options hash passed through to Rails' +collection_select+ helper
363
+ # @param form_group [Hash] configures the form group
364
+ # @option form_group classes [Array,String] sets the form group's classes
365
+ # @option form_group args [Hash] additional attributes added to the form group
315
366
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
367
+ # @see https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select Rails collection_select (called by govuk_collection_select)
316
368
  # @return [ActiveSupport::SafeBuffer] HTML output
317
369
  #
318
370
  # @example A select box with hint
@@ -320,7 +372,7 @@ module GOVUKDesignSystemFormBuilder
320
372
  # @grades,
321
373
  # :id,
322
374
  # :name,
323
- # hint_text: "If you took the test more than once enter your highest grade"
375
+ # hint: { text: "If you took the test more than once enter your highest grade" }
324
376
  #
325
377
  # @example A select box with injected content
326
378
  # = f.govuk_collection_select(:favourite_colour, @colours, :id, :name) do
@@ -332,7 +384,7 @@ module GOVUKDesignSystemFormBuilder
332
384
  # = f.govuk_collection_select(:team, @teams, :id, :name) do
333
385
  # label: -> { tag.h3("Which team did you represent?") }
334
386
  #
335
- def govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, html_options: {}, hint_text: nil, label: {}, caption: {}, &block)
387
+ def govuk_collection_select(attribute_name, collection, value_method, text_method, options: {}, html_options: {}, hint: {}, label: {}, caption: {}, form_group: {}, &block)
336
388
  Elements::Select.new(
337
389
  self,
338
390
  object_name,
@@ -340,11 +392,12 @@ module GOVUKDesignSystemFormBuilder
340
392
  collection,
341
393
  value_method: value_method,
342
394
  text_method: text_method,
343
- hint_text: hint_text,
395
+ hint: hint,
344
396
  label: label,
345
397
  caption: caption,
346
398
  options: options,
347
399
  html_options: html_options,
400
+ form_group: form_group,
348
401
  &block
349
402
  ).html
350
403
  end
@@ -368,12 +421,15 @@ module GOVUKDesignSystemFormBuilder
368
421
  # @param hint_method [Symbol, Proc, nil] The method called against each member of the collection to provide the hint text.
369
422
  # When a +Proc+ is provided it must take a single argument that is a single member of the collection.
370
423
  # When a +nil+ value is provided the hint text will be retrieved from the locale. This is the default and param can be omitted.
371
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
424
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
425
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
426
+ # @option hint text [String] the hint text
427
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
372
428
  # @param legend [Hash,Proc] options for configuring the legend
373
429
  # @param inline [Boolean] controls whether the radio buttons are displayed inline or not
374
430
  # @param small [Boolean] controls whether small radio buttons are used instead of regular-sized ones
375
431
  # @param bold_labels [Boolean] controls whether the radio button labels are bold
376
- # @param classes [String] Classes to add to the radio button container.
432
+ # @param classes [Array,String] Classes to add to the radio button container.
377
433
  # @option legend text [String] the fieldset legend's text content
378
434
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
379
435
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
@@ -396,7 +452,7 @@ module GOVUKDesignSystemFormBuilder
396
452
  # ->(option) { option.name.upcase },
397
453
  # :description,
398
454
  # legend: { text: 'Pick your favourite colour', size: 'm' },
399
- # hint_text: 'If you cannot find the exact match choose something close',
455
+ # hint: { text: 'If you cannot find the exact match choose something close' },
400
456
  # inline: false
401
457
  #
402
458
  # @example A collection of radio buttons for grades with injected content
@@ -415,7 +471,7 @@ module GOVUKDesignSystemFormBuilder
415
471
  # :name,
416
472
  # legend: -> { tag.h3('Which category do you belong to?') }
417
473
  #
418
- 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, &block)
474
+ def govuk_collection_radio_buttons(attribute_name, collection, value_method, text_method, hint_method = nil, hint: {}, legend: {}, caption: {}, inline: false, small: false, bold_labels: false, classes: nil, form_group: {}, &block)
419
475
  Elements::Radios::Collection.new(
420
476
  self,
421
477
  object_name,
@@ -424,13 +480,14 @@ module GOVUKDesignSystemFormBuilder
424
480
  value_method: value_method,
425
481
  text_method: text_method,
426
482
  hint_method: hint_method,
427
- hint_text: hint_text,
483
+ hint: hint,
428
484
  legend: legend,
429
485
  caption: caption,
430
486
  inline: inline,
431
487
  small: small,
432
488
  bold_labels: bold_labels,
433
489
  classes: classes,
490
+ form_group: form_group,
434
491
  &block
435
492
  ).html
436
493
  end
@@ -443,7 +500,10 @@ module GOVUKDesignSystemFormBuilder
443
500
  # is set to +link_errors: true+
444
501
  #
445
502
  # @param attribute_name [Symbol] The name of the attribute
446
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
503
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
504
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
505
+ # @option hint text [String] the hint text
506
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
447
507
  # @param legend [Hash,Proc] options for configuring the legend
448
508
  # @param inline [Boolean] controls whether the radio buttons are displayed inline or not
449
509
  # @param small [Boolean] controls whether small radio buttons are used instead of regular-sized ones
@@ -454,8 +514,11 @@ module GOVUKDesignSystemFormBuilder
454
514
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
455
515
  # @option caption text [String] the caption text
456
516
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
517
+ # @param form_group [Hash] configures the form group
518
+ # @option form_group classes [Array,String] sets the form group's classes
519
+ # @option form_group args [Hash] additional attributes added to the form group
457
520
  # @param block [Block] a block of HTML that will be used to populate the fieldset
458
- # @param classes [String] Classes to add to the radio button container.
521
+ # @param classes [Array,String] Classes to add to the radio button container.
459
522
  # @see https://design-system.service.gov.uk/components/radios/ GOV.UK Radios
460
523
  # @see https://design-system.service.gov.uk/styles/typography/#headings-with-captions Headings with captions
461
524
  # @return [ActiveSupport::SafeBuffer] HTML output
@@ -477,15 +540,18 @@ module GOVUKDesignSystemFormBuilder
477
540
  # = f.govuk_radio_button :burger_id, :regular, label: { text: 'Hamburger' }, link_errors: true
478
541
  # = f.govuk_radio_button :burger_id, :cheese, label: { text: 'Cheeseburger' }
479
542
  #
480
- def govuk_radio_buttons_fieldset(attribute_name, hint_text: nil, legend: {}, caption: {}, inline: false, small: false, classes: nil, &block)
481
- Containers::RadioButtonsFieldset.new(self, object_name, attribute_name, hint_text: hint_text, legend: legend, caption: caption, inline: inline, small: small, classes: classes, &block).html
543
+ def govuk_radio_buttons_fieldset(attribute_name, hint: {}, legend: {}, caption: {}, inline: false, small: false, classes: nil, form_group: {}, &block)
544
+ 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
482
545
  end
483
546
 
484
547
  # Generates a radio button
485
548
  #
486
549
  # @note This should only be used from within a {#govuk_radio_buttons_fieldset}
487
550
  # @param attribute_name [Symbol] The name of the attribute
488
- # @param hint_text [String] the contents of the hint
551
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
552
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
553
+ # @option hint text [String] the hint text
554
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
489
555
  # @option legend text [String] the fieldset legend's text content
490
556
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
491
557
  # @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
@@ -503,8 +569,8 @@ module GOVUKDesignSystemFormBuilder
503
569
  # = f.govuk_radio_buttons_fieldset :favourite_colour do
504
570
  # = f.govuk_radio_button :favourite_colour, :red, label: { text: 'Red' }
505
571
  #
506
- def govuk_radio_button(attribute_name, value, hint_text: nil, label: {}, link_errors: false, &block)
507
- Elements::Radios::FieldsetRadioButton.new(self, object_name, attribute_name, value, hint_text: hint_text, label: label, link_errors: link_errors, &block).html
572
+ def govuk_radio_button(attribute_name, value, hint: {}, label: {}, link_errors: false, &block)
573
+ Elements::Radios::FieldsetRadioButton.new(self, object_name, attribute_name, value, hint: hint, label: label, link_errors: link_errors, &block).html
508
574
  end
509
575
 
510
576
  # Inserts a text divider into a list of radio buttons
@@ -527,9 +593,12 @@ module GOVUKDesignSystemFormBuilder
527
593
  # @param text_method [Symbol] The method called against each member of the collection to provide the label text
528
594
  # @param hint_method [Symbol, Proc] The method called against each member of the collection to provide the hint text.
529
595
  # When a +Proc+ is provided it must take a single argument that is a single member of the collection
530
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
596
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
597
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
598
+ # @option hint text [String] the hint text
599
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
531
600
  # @param small [Boolean] controls whether small check boxes are used instead of regular-sized ones
532
- # @param classes [String] Classes to add to the checkbox container.
601
+ # @param classes [Array,String] Classes to add to the checkbox container.
533
602
  # @param legend [Hash,Proc] options for configuring the legend
534
603
  # @option legend text [String] the fieldset legend's text content
535
604
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
@@ -538,6 +607,9 @@ module GOVUKDesignSystemFormBuilder
538
607
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
539
608
  # @option caption text [String] the caption text
540
609
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
610
+ # @param form_group [Hash] configures the form group
611
+ # @option form_group classes [Array,String] sets the form group's classes
612
+ # @option form_group args [Hash] additional attributes added to the form group
541
613
  # @param block [Block] any HTML passed in will be injected into the fieldset, after the hint and before the checkboxes
542
614
  # @return [ActiveSupport::SafeBuffer] HTML output
543
615
  #
@@ -554,7 +626,7 @@ module GOVUKDesignSystemFormBuilder
554
626
  # :name,
555
627
  # :description,
556
628
  # legend: { text: 'What do you want in your sandwich?', size: 'm' },
557
- # hint_text: "If it isn't listed here, tough luck",
629
+ # hint: { text: "If it isn't listed here, tough luck" },
558
630
  # inline: false,
559
631
  # classes: 'app-overflow-scroll',
560
632
  #
@@ -574,7 +646,7 @@ module GOVUKDesignSystemFormBuilder
574
646
  # :name,
575
647
  # legend: -> { tag.h3('What kind of sandwich do you want?') }
576
648
  #
577
- def govuk_collection_check_boxes(attribute_name, collection, value_method, text_method, hint_method = nil, hint_text: nil, legend: {}, caption: {}, small: false, classes: nil, &block)
649
+ 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)
578
650
  Elements::CheckBoxes::Collection.new(
579
651
  self,
580
652
  object_name,
@@ -583,11 +655,12 @@ module GOVUKDesignSystemFormBuilder
583
655
  value_method: value_method,
584
656
  text_method: text_method,
585
657
  hint_method: hint_method,
586
- hint_text: hint_text,
658
+ hint: hint,
587
659
  legend: legend,
588
660
  caption: caption,
589
661
  small: small,
590
662
  classes: classes,
663
+ form_group: form_group,
591
664
  &block
592
665
  ).html
593
666
  end
@@ -598,7 +671,10 @@ module GOVUKDesignSystemFormBuilder
598
671
  # is set to +link_errors: true+
599
672
  #
600
673
  # @param attribute_name [Symbol] The name of the attribute
601
- # @param hint_text [String] The content of the fieldset hint. No hint will be injected if left +nil+
674
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
675
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
676
+ # @option hint text [String] the hint text
677
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
602
678
  # @param small [Boolean] controls whether small check boxes are used instead of regular-sized ones
603
679
  # @param legend [Hash,Proc] options for configuring the legend
604
680
  # @option legend text [String] the fieldset legend's text content
@@ -608,7 +684,10 @@ module GOVUKDesignSystemFormBuilder
608
684
  # @param caption [Hash] configures or sets the caption content which is inserted above the legend
609
685
  # @option caption text [String] the caption text
610
686
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
611
- # @param classes [String] Classes to add to the checkbox container.
687
+ # @param classes [Array,String] Classes to add to the checkbox container.
688
+ # @param form_group [Hash] configures the form group
689
+ # @option form_group classes [Array,String] sets the form group's classes
690
+ # @option form_group args [Hash] additional attributes added to the form group
612
691
  # @param block [Block] a block of HTML that will be used to populate the fieldset
613
692
  # @return [ActiveSupport::SafeBuffer] HTML output
614
693
  #
@@ -622,16 +701,17 @@ module GOVUKDesignSystemFormBuilder
622
701
  # = f.govuk_check_box :desired_filling, :lemonade, label: { text: 'Lemonade' }, link_errors: true
623
702
  # = f.govuk_check_box :desired_filling, :fizzy_orange, label: { text: 'Fizzy orange' }
624
703
  #
625
- def govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint_text: {}, small: false, classes: nil, &block)
704
+ def govuk_check_boxes_fieldset(attribute_name, legend: {}, caption: {}, hint: {}, small: false, classes: nil, form_group: {}, &block)
626
705
  Containers::CheckBoxesFieldset.new(
627
706
  self,
628
707
  object_name,
629
708
  attribute_name,
630
- hint_text: hint_text,
709
+ hint: hint,
631
710
  legend: legend,
632
711
  caption: caption,
633
712
  small: small,
634
713
  classes: classes,
714
+ form_group: form_group,
635
715
  &block
636
716
  ).html
637
717
  end
@@ -640,7 +720,10 @@ module GOVUKDesignSystemFormBuilder
640
720
  #
641
721
  # @param attribute_name [Symbol] The name of the attribute
642
722
  # @param value [Boolean,String,Symbol,Integer] The value of the checkbox when it is checked
643
- # @param hint_text [String] the contents of the hint
723
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
724
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
725
+ # @option hint text [String] the hint text
726
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
644
727
  # @param link_errors [Boolean] controls whether this radio button should be linked to from {#govuk_error_summary}
645
728
  # @option label text [String] the label text
646
729
  # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
@@ -656,15 +739,15 @@ module GOVUKDesignSystemFormBuilder
656
739
  # multiple: false,
657
740
  # link_errors: true,
658
741
  # label: { text: 'Do you agree with our terms and conditions?' },
659
- # hint_text: 'You will not be able to proceed unless you do'
742
+ # hint: { text: 'You will not be able to proceed unless you do' }
660
743
  #
661
- def govuk_check_box(attribute_name, value, hint_text: nil, label: {}, link_errors: false, multiple: true, &block)
744
+ def govuk_check_box(attribute_name, value, hint: {}, label: {}, link_errors: false, multiple: true, &block)
662
745
  Elements::CheckBoxes::FieldsetCheckBox.new(
663
746
  self,
664
747
  object_name,
665
748
  attribute_name,
666
749
  value,
667
- hint_text: hint_text,
750
+ hint: hint,
668
751
  label: label,
669
752
  link_errors: link_errors,
670
753
  multiple: multiple,
@@ -677,7 +760,7 @@ module GOVUKDesignSystemFormBuilder
677
760
  # @param text [String] the button text
678
761
  # @param warning [Boolean] makes the button red ({https://design-system.service.gov.uk/components/button/#warning-buttons warning}) when true
679
762
  # @param secondary [Boolean] makes the button grey ({https://design-system.service.gov.uk/components/button/#secondary-buttons secondary}) when true
680
- # @param classes [String] Classes to add to the submit button
763
+ # @param classes [Array,String] Classes to add to the submit button
681
764
  # @param prevent_double_click [Boolean] adds JavaScript to safeguard the
682
765
  # form from being submitted more than once
683
766
  # @param validate [Boolean] adds the formnovalidate to the submit button when true, this disables all
@@ -708,7 +791,10 @@ module GOVUKDesignSystemFormBuilder
708
791
  # of {https://bugs.ruby-lang.org/issues/5988 this} bug, so incorrect dates like +2019-09-31+ will
709
792
  # be 'rounded' up to +2019-10-01+.
710
793
  # @param attribute_name [Symbol] The name of the attribute
711
- # @param hint_text [String] the contents of the hint
794
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
795
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
796
+ # @option hint text [String] the hint text
797
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
712
798
  # @param legend [Hash,Proc] options for configuring the legend
713
799
  # @option legend text [String] the fieldset legend's text content
714
800
  # @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
@@ -718,6 +804,9 @@ module GOVUKDesignSystemFormBuilder
718
804
  # @option caption text [String] the caption text
719
805
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
720
806
  # @param omit_day [Boolean] do not render a day input, only capture month and year
807
+ # @param form_group [Hash] configures the form group
808
+ # @option form_group classes [Array,String] sets the form group's classes
809
+ # @option form_group args [Hash] additional attributes added to the form group
721
810
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input group
722
811
  # @param date_of_birth [Boolean] if +true+ {https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#Values birth date auto completion attributes}
723
812
  # will be added to the inputs
@@ -729,7 +818,7 @@ module GOVUKDesignSystemFormBuilder
729
818
  # @example A regular date input with a legend, hint and injected content
730
819
  # = f.govuk_date_field :starts_on,
731
820
  # legend: { 'When does your event start?' },
732
- # hint_text: 'Leave this field blank if you don't know exactly' } do
821
+ # hint: { text: 'Leave this field blank if you don't know exactly' } do
733
822
  #
734
823
  # p.govuk-inset-text
735
824
  # | If you don't fill this in you won't be eligable for a refund
@@ -737,8 +826,8 @@ module GOVUKDesignSystemFormBuilder
737
826
  # @example A date input with legend supplied as a proc
738
827
  # = f.govuk_date_field :finishes_on,
739
828
  # legend: -> { tag.h3('Which category do you belong to?') }
740
- def govuk_date_field(attribute_name, hint_text: nil, legend: {}, caption: {}, date_of_birth: false, omit_day: false, &block)
741
- 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, &block).html
829
+ def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, form_group: {}, &block)
830
+ 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
742
831
  end
743
832
 
744
833
  # Generates a summary of errors in the form, each linking to the corresponding
@@ -794,8 +883,14 @@ module GOVUKDesignSystemFormBuilder
794
883
  # @param caption [Hash] configures or sets the caption content which is inserted above the label
795
884
  # @option caption text [String] the caption text
796
885
  # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
797
- # @param hint_text [String] The content of the hint. No hint will be injected if left +nil+
886
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
887
+ # supplied the hint will be wrapped in a +div+ instead of a +span+
888
+ # @option hint text [String] the hint text
889
+ # @option hint args [Hash] additional arguments are applied as attributes to the hint
798
890
  # @option args [Hash] args additional arguments are applied as attributes to the +input+ element
891
+ # @param form_group [Hash] configures the form group
892
+ # @option form_group classes [Array,String] sets the form group's classes
893
+ # @option form_group args [Hash] additional attributes added to the form group
799
894
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
800
895
  #
801
896
  # @example A photo upload field with file type specifier and injected content
@@ -814,8 +909,8 @@ module GOVUKDesignSystemFormBuilder
814
909
  # @note Remember to set +multipart: true+ when creating a form with file
815
910
  # uploads, {https://guides.rubyonrails.org/form_helpers.html#uploading-files see
816
911
  # the Rails documentation} for more information
817
- def govuk_file_field(attribute_name, label: {}, caption: {}, hint_text: nil, **args, &block)
818
- Elements::File.new(self, object_name, attribute_name, label: label, caption: caption, hint_text: hint_text, **args, &block).html
912
+ def govuk_file_field(attribute_name, label: {}, caption: {}, hint: {}, form_group: {}, **args, &block)
913
+ Elements::File.new(self, object_name, attribute_name, label: label, caption: caption, hint: hint, form_group: form_group, **args, &block).html
819
914
  end
820
915
  end
821
916
  end