mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
chore(Form Node): Add dropdown example (#18809)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -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, '<').replace(/>/g, '>');
|
||||
}
|
||||
|
||||
@@ -243,7 +250,6 @@ export const tryToParseJsonToFormFields = (value: unknown): FormFieldsParameter
|
||||
|
||||
throw new ApplicationError('Value is not valid JSON');
|
||||
}
|
||||
|
||||
return fields;
|
||||
};
|
||||
|
||||
|
||||
@@ -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": "<div>test</div>"}]';
|
||||
const fields = tryToParseJsonToFormFields(json);
|
||||
expect(fields).toEqual([{ fieldType: 'html', html: '<div>test</div>' }]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user