Skip to content

Commit 699fd70

Browse files
feat(n8n Form Trigger Node): Option to remove attribution (#9162)
1 parent 85780ea commit 699fd70

File tree

5 files changed

+56
-32
lines changed

5 files changed

+56
-32
lines changed

cypress/e2e/16-form-trigger-node.cy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('n8n Form Trigger', () => {
7878

7979
//add optional submitted message
8080
cy.get('.param-options').click();
81+
getVisibleSelect().find('span').contains('Form Response').click();
8182
cy.contains('span', 'Text to Show')
8283
.should('exist')
8384
.parent()

packages/cli/templates/form-trigger.handlebars

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -354,37 +354,40 @@
354354
</div>
355355
</div>
356356

357-
<div class='n8n-link'>
358-
<a href={{n8nWebsiteLink}} target='_blank'>
359-
Form automated with
360-
<svg
361-
width='73'
362-
height='20'
363-
viewBox='0 0 73 20'
364-
fill='none'
365-
xmlns='http://www.w3.org/2000/svg'
366-
>
367-
<path
368-
fill-rule='evenodd'
369-
clip-rule='evenodd'
370-
d='M40.2373 4C40.2373 6.20915 38.4464 8 36.2373 8C34.3735 8 32.8074 6.72525 32.3633 5H26.7787C25.801 5 24.9666 5.70685 24.8059 6.6712L24.6415 7.6576C24.4854 8.59415 24.0116 9.40925 23.3417 10C24.0116 10.5907 24.4854 11.4058 24.6415 12.3424L24.8059 13.3288C24.9666 14.2931 25.801 15 26.7787 15H28.3633C28.8074 13.2747 30.3735 12 32.2373 12C34.4464 12 36.2373 13.7908 36.2373 16C36.2373 18.2092 34.4464 20 32.2373 20C30.3735 20 28.8074 18.7253 28.3633 17H26.7787C24.8233 17 23.1546 15.5864 22.8331 13.6576L22.6687 12.6712C22.508 11.7069 21.6736 11 20.6959 11H19.0645C18.5652 12.64 17.0406 13.8334 15.2373 13.8334C13.434 13.8334 11.9094 12.64 11.4101 11H9.06449C8.56519 12.64 7.04059 13.8334 5.2373 13.8334C3.02817 13.8334 1.2373 12.0424 1.2373 9.83335C1.2373 7.6242 3.02817 5.83335 5.2373 5.83335C7.16069 5.83335 8.76699 7.19085 9.15039 9H11.3242C11.7076 7.19085 13.3139 5.83335 15.2373 5.83335C17.1607 5.83335 18.767 7.19085 19.1504 9H20.6959C21.6736 9 22.508 8.29315 22.6687 7.3288L22.8331 6.3424C23.1546 4.41365 24.8233 3 26.7787 3H32.3633C32.8074 1.27478 34.3735 0 36.2373 0C38.4464 0 40.2373 1.79086 40.2373 4ZM38.2373 4C38.2373 5.10455 37.3419 6 36.2373 6C35.1327 6 34.2373 5.10455 34.2373 4C34.2373 2.89543 35.1327 2 36.2373 2C37.3419 2 38.2373 2.89543 38.2373 4ZM5.2373 11.8334C6.34189 11.8334 7.23729 10.9379 7.23729 9.83335C7.23729 8.72875 6.34189 7.83335 5.2373 7.83335C4.13273 7.83335 3.2373 8.72875 3.2373 9.83335C3.2373 10.9379 4.13273 11.8334 5.2373 11.8334ZM15.2373 11.8334C16.3419 11.8334 17.2373 10.9379 17.2373 9.83335C17.2373 8.72875 16.3419 7.83335 15.2373 7.83335C14.1327 7.83335 13.2373 8.72875 13.2373 9.83335C13.2373 10.9379 14.1327 11.8334 15.2373 11.8334ZM32.2373 18C33.3419 18 34.2373 17.1045 34.2373 16C34.2373 14.8954 33.3419 14 32.2373 14C31.1327 14 30.2373 14.8954 30.2373 16C30.2373 17.1045 31.1327 18 32.2373 18Z'
371-
fill='#EA4B71'
372-
/>
373-
<path
374-
d='M44.2393 15.0007H46.3277V10.5791C46.3277 9.12704 47.2088 8.49074 48.204 8.49074C49.183 8.49074 49.9498 9.14334 49.9498 10.4812V15.0007H52.038V10.057C52.038 7.91969 50.798 6.67969 48.8567 6.67969C47.633 6.67969 46.9477 7.16914 46.4582 7.80544H46.3277L46.1482 6.84284H44.2393V15.0007Z'
375-
fill='#101330'
376-
/>
377-
<path
378-
d='M60.0318 9.50205V9.40415C60.7498 9.0452 61.4678 8.4252 61.4678 7.20155C61.4678 5.43945 60.0153 4.37891 58.0088 4.37891C55.9528 4.37891 54.4843 5.5047 54.4843 7.23415C54.4843 8.4089 55.1698 9.0452 55.9203 9.40415V9.50205C55.0883 9.79575 54.0928 10.6768 54.0928 12.1452C54.0928 13.9237 55.5613 15.1637 57.9923 15.1637C60.4233 15.1637 61.8428 13.9237 61.8428 12.1452C61.8428 10.6768 60.8638 9.81205 60.0318 9.50205ZM57.9923 5.87995C58.8083 5.87995 59.4118 6.40205 59.4118 7.2831C59.4118 8.16415 58.7918 8.6863 57.9923 8.6863C57.1928 8.6863 56.5238 8.16415 56.5238 7.2831C56.5238 6.38575 57.1603 5.87995 57.9923 5.87995ZM57.9923 13.5974C57.0458 13.5974 56.2793 12.9937 56.2793 11.9658C56.2793 11.0358 56.9153 10.3342 57.9758 10.3342C59.0203 10.3342 59.6568 11.0195 59.6568 11.9984C59.6568 12.9937 58.9223 13.5974 57.9923 13.5974Z'
379-
fill='#101330'
380-
/>
381-
<path
382-
d='M63.9639 15.0007H66.0524V10.5791C66.0524 9.12704 66.9334 8.49074 67.9289 8.49074C68.9079 8.49074 69.6744 9.14334 69.6744 10.4812V15.0007H71.7629V10.057C71.7629 7.91969 70.5229 6.67969 68.5814 6.67969C67.3579 6.67969 66.6724 7.16914 66.1829 7.80544H66.0524L65.8729 6.84284H63.9639V15.0007Z'
383-
fill='#101330'
384-
/>
385-
</svg>
386-
</a>
387-
</div>
357+
{{#if appendAttribution}}
358+
<div class='n8n-link'>
359+
<a href={{n8nWebsiteLink}} target='_blank'>
360+
Form automated with
361+
<svg
362+
width='73'
363+
height='20'
364+
viewBox='0 0 73 20'
365+
fill='none'
366+
xmlns='http://www.w3.org/2000/svg'
367+
>
368+
<path
369+
fill-rule='evenodd'
370+
clip-rule='evenodd'
371+
d='M40.2373 4C40.2373 6.20915 38.4464 8 36.2373 8C34.3735 8 32.8074 6.72525 32.3633 5H26.7787C25.801 5 24.9666 5.70685 24.8059 6.6712L24.6415 7.6576C24.4854 8.59415 24.0116 9.40925 23.3417 10C24.0116 10.5907 24.4854 11.4058 24.6415 12.3424L24.8059 13.3288C24.9666 14.2931 25.801 15 26.7787 15H28.3633C28.8074 13.2747 30.3735 12 32.2373 12C34.4464 12 36.2373 13.7908 36.2373 16C36.2373 18.2092 34.4464 20 32.2373 20C30.3735 20 28.8074 18.7253 28.3633 17H26.7787C24.8233 17 23.1546 15.5864 22.8331 13.6576L22.6687 12.6712C22.508 11.7069 21.6736 11 20.6959 11H19.0645C18.5652 12.64 17.0406 13.8334 15.2373 13.8334C13.434 13.8334 11.9094 12.64 11.4101 11H9.06449C8.56519 12.64 7.04059 13.8334 5.2373 13.8334C3.02817 13.8334 1.2373 12.0424 1.2373 9.83335C1.2373 7.6242 3.02817 5.83335 5.2373 5.83335C7.16069 5.83335 8.76699 7.19085 9.15039 9H11.3242C11.7076 7.19085 13.3139 5.83335 15.2373 5.83335C17.1607 5.83335 18.767 7.19085 19.1504 9H20.6959C21.6736 9 22.508 8.29315 22.6687 7.3288L22.8331 6.3424C23.1546 4.41365 24.8233 3 26.7787 3H32.3633C32.8074 1.27478 34.3735 0 36.2373 0C38.4464 0 40.2373 1.79086 40.2373 4ZM38.2373 4C38.2373 5.10455 37.3419 6 36.2373 6C35.1327 6 34.2373 5.10455 34.2373 4C34.2373 2.89543 35.1327 2 36.2373 2C37.3419 2 38.2373 2.89543 38.2373 4ZM5.2373 11.8334C6.34189 11.8334 7.23729 10.9379 7.23729 9.83335C7.23729 8.72875 6.34189 7.83335 5.2373 7.83335C4.13273 7.83335 3.2373 8.72875 3.2373 9.83335C3.2373 10.9379 4.13273 11.8334 5.2373 11.8334ZM15.2373 11.8334C16.3419 11.8334 17.2373 10.9379 17.2373 9.83335C17.2373 8.72875 16.3419 7.83335 15.2373 7.83335C14.1327 7.83335 13.2373 8.72875 13.2373 9.83335C13.2373 10.9379 14.1327 11.8334 15.2373 11.8334ZM32.2373 18C33.3419 18 34.2373 17.1045 34.2373 16C34.2373 14.8954 33.3419 14 32.2373 14C31.1327 14 30.2373 14.8954 30.2373 16C30.2373 17.1045 31.1327 18 32.2373 18Z'
372+
fill='#EA4B71'
373+
/>
374+
<path
375+
d='M44.2393 15.0007H46.3277V10.5791C46.3277 9.12704 47.2088 8.49074 48.204 8.49074C49.183 8.49074 49.9498 9.14334 49.9498 10.4812V15.0007H52.038V10.057C52.038 7.91969 50.798 6.67969 48.8567 6.67969C47.633 6.67969 46.9477 7.16914 46.4582 7.80544H46.3277L46.1482 6.84284H44.2393V15.0007Z'
376+
fill='#101330'
377+
/>
378+
<path
379+
d='M60.0318 9.50205V9.40415C60.7498 9.0452 61.4678 8.4252 61.4678 7.20155C61.4678 5.43945 60.0153 4.37891 58.0088 4.37891C55.9528 4.37891 54.4843 5.5047 54.4843 7.23415C54.4843 8.4089 55.1698 9.0452 55.9203 9.40415V9.50205C55.0883 9.79575 54.0928 10.6768 54.0928 12.1452C54.0928 13.9237 55.5613 15.1637 57.9923 15.1637C60.4233 15.1637 61.8428 13.9237 61.8428 12.1452C61.8428 10.6768 60.8638 9.81205 60.0318 9.50205ZM57.9923 5.87995C58.8083 5.87995 59.4118 6.40205 59.4118 7.2831C59.4118 8.16415 58.7918 8.6863 57.9923 8.6863C57.1928 8.6863 56.5238 8.16415 56.5238 7.2831C56.5238 6.38575 57.1603 5.87995 57.9923 5.87995ZM57.9923 13.5974C57.0458 13.5974 56.2793 12.9937 56.2793 11.9658C56.2793 11.0358 56.9153 10.3342 57.9758 10.3342C59.0203 10.3342 59.6568 11.0195 59.6568 11.9984C59.6568 12.9937 58.9223 13.5974 57.9923 13.5974Z'
380+
fill='#101330'
381+
/>
382+
<path
383+
d='M63.9639 15.0007H66.0524V10.5791C66.0524 9.12704 66.9334 8.49074 67.9289 8.49074C68.9079 8.49074 69.6744 9.14334 69.6744 10.4812V15.0007H71.7629V10.057C71.7629 7.91969 70.5229 6.67969 68.5814 6.67969C67.3579 6.67969 66.6724 7.16914 66.1829 7.80544H66.0524L65.8729 6.84284H63.9639V15.0007Z'
384+
fill='#101330'
385+
/>
386+
</svg>
387+
</a>
388+
</div>
389+
{{/if}}
390+
388391
{{#if redirectUrl}}
389392
<a id='redirectUrl' href='{{redirectUrl}}' style='display: none;'></a>
390393
{{/if}}

packages/nodes-base/nodes/Form/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ export type FormTriggerData = {
3030
n8nWebsiteLink: string;
3131
formFields: FormTriggerInput[];
3232
useResponseData?: boolean;
33+
appendAttribution?: boolean;
3334
};

packages/nodes-base/nodes/Form/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const prepareFormData = (
1010
testRun: boolean,
1111
instanceId?: string,
1212
useResponseData?: boolean,
13+
appendAttribution = true,
1314
) => {
1415
const validForm = formFields.length > 0;
1516
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
@@ -28,6 +29,7 @@ export const prepareFormData = (
2829
n8nWebsiteLink,
2930
formFields: [],
3031
useResponseData,
32+
appendAttribution,
3133
};
3234

3335
if (redirectUrl) {
@@ -90,6 +92,7 @@ export async function formWebhook(context: IWebhookFunctions) {
9092

9193
let formSubmittedText;
9294
let redirectUrl;
95+
let appendAttribution = true;
9396

9497
if (options.respondWithOptions) {
9598
const values = (options.respondWithOptions as IDataObject).values as IDataObject;
@@ -103,6 +106,10 @@ export async function formWebhook(context: IWebhookFunctions) {
103106
formSubmittedText = options.formSubmittedText as string;
104107
}
105108

109+
if (options.appendAttribution === false) {
110+
appendAttribution = false;
111+
}
112+
106113
const useResponseData = responseMode === 'responseNode';
107114

108115
const data = prepareFormData(
@@ -114,6 +121,7 @@ export async function formWebhook(context: IWebhookFunctions) {
114121
mode === 'test',
115122
instanceId,
116123
useResponseData,
124+
appendAttribution,
117125
);
118126

119127
const res = context.getResponseObject();

packages/nodes-base/nodes/Form/v2/FormTriggerV2.node.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,18 @@ const descriptionV2: INodeTypeDescription = {
8181
responseMode: ['responseNode'],
8282
},
8383
},
84-
options: [respondWithOptions],
84+
options: [
85+
{
86+
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
87+
displayName: 'Append n8n Attribution',
88+
name: 'appendAttribution',
89+
type: 'boolean',
90+
default: true,
91+
description:
92+
'Whether to include the link “Form automated with n8n” at the bottom of the form',
93+
},
94+
respondWithOptions,
95+
],
8596
},
8697
],
8798
};

0 commit comments

Comments
 (0)