Skip to content

Preview: Add allow-forms to iframe sandbox attributes#20701

Merged
AndyButland merged 1 commit intomainfrom
v17/bugfix/preview-mode-forms-sandbox
Oct 31, 2025
Merged

Preview: Add allow-forms to iframe sandbox attributes#20701
AndyButland merged 1 commit intomainfrom
v17/bugfix/preview-mode-forms-sandbox

Conversation

@rickbutterfield
Copy link
Contributor

Description

When viewing a page in Preview mode and attempting to submit a form (either a standard form POST or Umbraco Forms), an error occurs in the browser console and the form is not submitted:

Blocked form submission to '/form-submission-endpoint' because the form's frame is sandboxed and the 'allow-forms' permission is not set.

image

Umbraco Forms allows content editors to "Save and preview" forms from the backoffice, and we are aware of users that do test their forms this way.

This PR resolves that issue by adding the allow-forms value to the preview iframe's sandbox attribute.

Testing

This can be replicated on a blank install of CMS with the Starter Kit (both in 16.3.4 and 17.0.0-rc1)

dotnet new install [email protected]
dotnet new umbraco --name TestProject
cd .\TestProject\
dotnet add package Umbraco.TheStarterKit --version 16.0.0
dotnet run

Once Umbraco is installed and running:

  • navigate to the Contact page in the backoffice
  • press the "Save and preview" button
  • On the loaded Contact page preview, open the dev tools
  • Fill out the form and attempt to submit it

Observe that the error listed above shows in the dev tools console.

Copilot AI review requested due to automatic review settings October 31, 2025 11:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the preview iframe's sandbox permissions by adding form submission capability. The change enables forms within the preview iframe to function properly, which is essential for testing user interactions in the preview environment.

Key changes:

  • Added allow-forms attribute to the iframe sandbox permissions

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rickbutterfield - will merge this in for 17.1 and cherry-pick it to also be part of 16.4.

@AndyButland AndyButland merged commit 4fc79ad into main Oct 31, 2025
35 checks passed
@AndyButland AndyButland deleted the v17/bugfix/preview-mode-forms-sandbox branch October 31, 2025 12:34
AndyButland pushed a commit that referenced this pull request Oct 31, 2025
Add 'allow-forms' to iframe sandbox attributes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants