Skip to content

Commit 424d633

Browse files
committed
Update example and documentation for JS file upload
1 parent e936150 commit 424d633

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

guide/content/form-elements/file-upload.slim

+4
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ p.govuk-body
1414
caption: 'File upload with label and hint',
1515
code: file_upload)
1616

17+
== render('/partials/example.*',
18+
caption: 'Javascript-enhanced file upload with label and hint',
19+
code: file_upload_javascript)
20+
1721
== render('/partials/related-navigation.*', links: file_info)

guide/lib/examples/file.rb

+9
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ def file_upload
77
hint: { text: 'Upload a clear colour photograph of yourself looking straight at the camera' }
88
SNIPPET
99
end
10+
11+
def file_upload_javascript
12+
<<~SNIPPET
13+
= f.govuk_file_field :profile_photo,
14+
label: { text: 'Identification photograph' },
15+
hint: { text: 'Upload a clear colour photograph of yourself looking straight at the camera' },
16+
javascript: true
17+
SNIPPET
18+
end
1019
end
1120
end

lib/govuk_design_system_formbuilder/builder.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,7 @@ def govuk_fieldset(legend: { text: 'Fieldset heading' }, caption: {}, described_
10461046
# @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
10471047
# @param form_group [Hash] configures the form group
10481048
# @option form_group kwargs [Hash] additional attributes added to the form group
1049+
# @param javascript [Boolean] Configures whether to add HTML for the javascript-enhanced version of the component
10491050
# @param block [Block] arbitrary HTML that will be rendered between the hint and the input
10501051
#
10511052
# @example A photo upload field with file type specifier and injected content

0 commit comments

Comments
 (0)