mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
feat(n8n Form Trigger Node): Option to remove attribution (#9162)
This commit is contained in:
parent
85780eade5
commit
699fd70c24
|
@ -78,6 +78,7 @@ describe('n8n Form Trigger', () => {
|
|||
|
||||
//add optional submitted message
|
||||
cy.get('.param-options').click();
|
||||
getVisibleSelect().find('span').contains('Form Response').click();
|
||||
cy.contains('span', 'Text to Show')
|
||||
.should('exist')
|
||||
.parent()
|
||||
|
|
|
@ -354,6 +354,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{#if appendAttribution}}
|
||||
<div class='n8n-link'>
|
||||
<a href={{n8nWebsiteLink}} target='_blank'>
|
||||
Form automated with
|
||||
|
@ -385,6 +386,8 @@
|
|||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if redirectUrl}}
|
||||
<a id='redirectUrl' href='{{redirectUrl}}' style='display: none;'></a>
|
||||
{{/if}}
|
||||
|
|
|
@ -30,4 +30,5 @@ export type FormTriggerData = {
|
|||
n8nWebsiteLink: string;
|
||||
formFields: FormTriggerInput[];
|
||||
useResponseData?: boolean;
|
||||
appendAttribution?: boolean;
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ export const prepareFormData = (
|
|||
testRun: boolean,
|
||||
instanceId?: string,
|
||||
useResponseData?: boolean,
|
||||
appendAttribution = true,
|
||||
) => {
|
||||
const validForm = formFields.length > 0;
|
||||
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
|
||||
|
@ -28,6 +29,7 @@ export const prepareFormData = (
|
|||
n8nWebsiteLink,
|
||||
formFields: [],
|
||||
useResponseData,
|
||||
appendAttribution,
|
||||
};
|
||||
|
||||
if (redirectUrl) {
|
||||
|
@ -90,6 +92,7 @@ export async function formWebhook(context: IWebhookFunctions) {
|
|||
|
||||
let formSubmittedText;
|
||||
let redirectUrl;
|
||||
let appendAttribution = true;
|
||||
|
||||
if (options.respondWithOptions) {
|
||||
const values = (options.respondWithOptions as IDataObject).values as IDataObject;
|
||||
|
@ -103,6 +106,10 @@ export async function formWebhook(context: IWebhookFunctions) {
|
|||
formSubmittedText = options.formSubmittedText as string;
|
||||
}
|
||||
|
||||
if (options.appendAttribution === false) {
|
||||
appendAttribution = false;
|
||||
}
|
||||
|
||||
const useResponseData = responseMode === 'responseNode';
|
||||
|
||||
const data = prepareFormData(
|
||||
|
@ -114,6 +121,7 @@ export async function formWebhook(context: IWebhookFunctions) {
|
|||
mode === 'test',
|
||||
instanceId,
|
||||
useResponseData,
|
||||
appendAttribution,
|
||||
);
|
||||
|
||||
const res = context.getResponseObject();
|
||||
|
|
|
@ -81,7 +81,18 @@ const descriptionV2: INodeTypeDescription = {
|
|||
responseMode: ['responseNode'],
|
||||
},
|
||||
},
|
||||
options: [respondWithOptions],
|
||||
options: [
|
||||
{
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
||||
displayName: 'Append n8n Attribution',
|
||||
name: 'appendAttribution',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to include the link “Form automated with n8n” at the bottom of the form',
|
||||
},
|
||||
respondWithOptions,
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue