Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions src/server/forms/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,83 +11,105 @@
"name": "textField",
"title": "Text field",
"hint": "Help text",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "MultilineTextField",
"name": "multilineTextField",
"title": "Multiline text field",
"hint": "Help text",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "NumberField",
"name": "numberField",
"title": "Number field",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "DatePartsField",
"name": "datePartsField",
"title": "Date parts field",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "YesNoField",
"name": "yesNoField",
"title": "Yes/No field",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "EmailAddressField",
"name": "emailAddressField",
"title": "Email address field",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "TelephoneNumberField",
"name": "telephoneNumberField",
"title": "Telephone number field",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "UkAddressField",
"name": "addressField",
"title": "UK address field",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "RadiosField",
"name": "radiosField",
"title": "Radios field",
"list": "companyType",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"type": "SelectField",
"name": "selectField",
"title": "Select field",
"list": "country",
"options": {},
"options": {
"required": false
},
"schema": {}
},
{
"options": {},
"list": "horseBreed",
"type": "CheckboxesField",
"name": "checkboxesField",
"title": "Checkboxes field",
"hint": "Please help",
"schema": {}
"schema": {},
"options": {
"required": false
}
},
{
"type": "Html",
Expand Down Expand Up @@ -126,7 +148,10 @@
"name": "declaration",
"title": "Declaration",
"content": "By submitting this form, I agree to:\n\n- Provide accurate and complete information\n- Comply with all applicable regulations\n- Accept responsibility for any false statements",
"hint": "Please read and confirm the following terms"
"hint": "Please read and confirm the following terms",
"options": {
"required": false
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ describe('DeclarationField', () => {
id: 'myComponent',
fieldset: {
legend: {
text: 'Example Declaration Component'
text: 'Example Declaration Component',
classes: 'govuk-fieldset__legend--m'
}
},
items: [
Expand Down
20 changes: 13 additions & 7 deletions src/server/plugins/engine/components/DeclarationField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,27 @@ export class DeclarationField extends FormComponent {
const defaultDeclarationConfirmationLabel =
'I confirm that I understand and accept this declaration'
const {
title,
hint,
content,
declarationConfirmationLabel = defaultDeclarationConfirmationLabel
} = this

const viewModel = super.getViewModel(payload, errors)
let { fieldset, label } = viewModel

fieldset ??= {
legend: {
text: label.text,
classes: 'govuk-fieldset__legend--m'
}
}

const isChecked =
payload[this.name] === 'true' || payload[this.name] === true
return {
...super.getViewModel(payload, errors),
...viewModel,
hint: hint ? { text: hint } : undefined,
fieldset: {
legend: {
text: title
}
},
fieldset,
content,
items: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ describe('QuestionPageController', () => {
checkboxesMultiple: [],
checkboxesSingleNumber: [],
checkboxesMultipleNumber: [],
fileUpload: null
fileUpload: null,
declaration: false
})

Object.assign(state, {
Expand All @@ -609,7 +610,8 @@ describe('QuestionPageController', () => {
checkboxesSingle: ['Shetland'],
checkboxesMultiple: ['Arabian', 'Shire', 'Race'],
checkboxesSingleNumber: [1],
checkboxesMultipleNumber: [0, 1]
checkboxesMultipleNumber: [0, 1],
declaration: true
})

request = buildFormContextRequest({
Expand Down Expand Up @@ -657,7 +659,8 @@ describe('QuestionPageController', () => {
checkboxesMultiple: ['Arabian', 'Shire', 'Race'],
checkboxesSingleNumber: [1],
checkboxesMultipleNumber: [0, 1],
fileUpload: null
fileUpload: null,
declaration: true
})

Object.assign(state, {
Expand Down Expand Up @@ -729,7 +732,8 @@ describe('QuestionPageController', () => {
checkboxesMultiple: ['Arabian', 'Shire', 'Race'],
checkboxesSingleNumber: [1],
checkboxesMultipleNumber: [0, 1],
fileUpload: ['fd5db541-179c-4107-a4d0-149d09672ffc']
fileUpload: ['fd5db541-179c-4107-a4d0-149d09672ffc'],
declaration: true
})
})
})
Expand Down
Loading
Loading