diff --git a/packages/nodes-base/nodes/Form/Form.node.ts b/packages/nodes-base/nodes/Form/Form.node.ts index 2870a195ce..5e02905e64 100644 --- a/packages/nodes-base/nodes/Form/Form.node.ts +++ b/packages/nodes-base/nodes/Form/Form.node.ts @@ -71,7 +71,7 @@ export const formFieldsProperties: INodeProperties[] = [ rows: 5, }, default: - '[\n {\n "fieldLabel":"Name",\n "placeholder":"enter you name",\n "requiredField":true\n },\n {\n "fieldLabel":"Age",\n "fieldType":"number",\n "placeholder":"enter your age"\n },\n {\n "fieldLabel":"Email",\n "fieldType":"email",\n "requiredField":true\n }\n]', + '[\n {\n "fieldLabel": "Name",\n "placeholder": "enter your name",\n "requiredField": true\n },\n {\n "fieldLabel": "Age",\n "fieldType": "number",\n "placeholder": "enter your age"\n },\n {\n "fieldLabel": "Email",\n "fieldType": "email",\n "requiredField": true\n },\n {\n "fieldLabel": "Textarea",\n "fieldType": "textarea"\n },\n {\n "fieldLabel": "Dropdown Options",\n "fieldType": "dropdown",\n "fieldOptions": {\n "values": [\n {\n "option": "option 1"\n },\n {\n "option": "option 2"\n }\n ]\n },\n "requiredField": true\n },\n {\n "fieldLabel": "Checkboxes",\n "fieldType": "checkbox",\n "fieldOptions": {\n "values": [\n {\n "option": "option 1"\n },\n {\n "option": "option 2"\n }\n ]\n }\n },\n {\n "fieldLabel": "Radio",\n "fieldType": "radio",\n "fieldOptions": {\n "values": [\n {\n "option": "option 1"\n },\n {\n "option": "option 2"\n }\n ]\n }\n },\n {\n "fieldLabel": "Email",\n "fieldType": "email",\n "placeholder": "me@mail.con"\n },\n {\n "fieldLabel": "File",\n "fieldType": "file",\n "multipleFiles": true,\n "acceptFileTypes": ".jpg, .png"\n },\n {\n "fieldLabel": "Number",\n "fieldType": "number"\n },\n {\n "fieldLabel": "Password",\n "fieldType": "password"\n }\n]\n', validateType: 'form-fields', ignoreValidationDuringExecution: true, hint: 'See docs for field syntax', diff --git a/packages/nodes-base/nodes/Form/common.descriptions.ts b/packages/nodes-base/nodes/Form/common.descriptions.ts index ffec13134e..77656720cf 100644 --- a/packages/nodes-base/nodes/Form/common.descriptions.ts +++ b/packages/nodes-base/nodes/Form/common.descriptions.ts @@ -89,6 +89,7 @@ export const formFields: INodeProperties = { type: 'options', default: 'text', description: 'The type of field to add to the form', + // Update ALLOWED_FIELD_TYPES in packages/workflow/src/type-validation.ts when adding new field types options: [ { name: 'Checkboxes', diff --git a/packages/workflow/src/type-validation.ts b/packages/workflow/src/type-validation.ts index 08d5408554..8bb6ba3df8 100644 --- a/packages/workflow/src/type-validation.ts +++ b/packages/workflow/src/type-validation.ts @@ -167,6 +167,9 @@ const ALLOWED_FORM_FIELDS_KEYS = [ 'acceptFileTypes', 'formatDate', 'requiredField', + 'fieldValue', + 'elementName', + 'html', ]; const ALLOWED_FIELD_TYPES = [ @@ -178,6 +181,10 @@ const ALLOWED_FIELD_TYPES = [ 'password', 'text', 'textarea', + 'checkbox', + 'radio', + 'html', + 'hiddenField', ]; export const tryToParseJsonToFormFields = (value: unknown): FormFieldsParameter => { @@ -198,7 +205,7 @@ export const tryToParseJsonToFormFields = (value: unknown): FormFieldsParameter !['string', 'number', 'boolean'].includes(typeof field[key]) ) { field[key] = String(field[key]); - } else if (typeof field[key] === 'string') { + } else if (typeof field[key] === 'string' && key !== 'html') { field[key] = field[key].replace(//g, '>'); } @@ -243,7 +250,6 @@ export const tryToParseJsonToFormFields = (value: unknown): FormFieldsParameter throw new ApplicationError('Value is not valid JSON'); } - return fields; }; diff --git a/packages/workflow/test/type-validation.test.ts b/packages/workflow/test/type-validation.test.ts index e3606c0caf..15dfe1be2e 100644 --- a/packages/workflow/test/type-validation.test.ts +++ b/packages/workflow/test/type-validation.test.ts @@ -1,6 +1,11 @@ import { DateTime, Settings } from 'luxon'; -import { getValueDescription, tryToParseDateTime, validateFieldType } from '../src/type-validation'; +import { + getValueDescription, + tryToParseDateTime, + tryToParseJsonToFormFields, + validateFieldType, +} from '../src/type-validation'; describe('Type Validation', () => { describe('string-alphanumeric', () => { @@ -359,4 +364,12 @@ describe('Type Validation', () => { expect(result.toISO()).toEqual('2025-01-01T00:00:00.000+09:00'); }); }); + + describe('tryToParseJsonToFormFields', () => { + it('should parse html field', () => { + const json = '[{"fieldType": "html", "html": "