diff --git a/packages/nodes-base/nodes/Cockpit/FormDescription.ts b/packages/nodes-base/nodes/Cockpit/FormDescription.ts index 8488cbe095..78f77ba548 100644 --- a/packages/nodes-base/nodes/Cockpit/FormDescription.ts +++ b/packages/nodes-base/nodes/Cockpit/FormDescription.ts @@ -44,21 +44,88 @@ export const formFields = [ // Form:submit { - displayName: 'Form data', - name: 'form', + displayName: 'JSON Data fields', + name: 'jsonDataFields', + type: 'boolean', + default: false, + displayOptions: { + show: { + resource: [ + 'form', + ], + operation: [ + 'submit', + ] + }, + }, + description: 'If form fields should be set via the value-key pair UI or JSON.', + }, + { + displayName: 'Form fields', + name: 'dataFieldsJson', type: 'json', - required: true, default: '', typeOptions: { alwaysOpenEditWindow: true, }, displayOptions: { show: { + jsonDataFields: [ + true, + ], resource: [ 'form', ], + operation: [ + 'submit', + ] }, }, - description: 'The data to save.', + description: 'Form to send as JSON.', + }, + { + displayName: 'Data fields', + name: 'dataFieldsUi', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + displayOptions: { + show: { + jsonDataFields: [ + false, + ], + resource: [ + 'form', + ], + operation: [ + 'submit', + ] + }, + }, + options: [ + { + displayName: 'Field', + name: 'field', + values: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of the field.', + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + description: 'Value of the field.', + }, + ], + }, + ], + description: 'Form field to send.', }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Cockpit/FormFunctions.ts b/packages/nodes-base/nodes/Cockpit/FormFunctions.ts index 437ed210a0..36a1bdc389 100644 --- a/packages/nodes-base/nodes/Cockpit/FormFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/FormFunctions.ts @@ -9,7 +9,7 @@ import { cockpitApiRequest } from './GenericFunctions'; export async function submitForm(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resourceName: string, form: IDataObject) { const body: IForm = { - form: JSON.parse(form.toString()) + form }; return cockpitApiRequest.call(this, 'post', `/forms/submit/${resourceName}`, body);