Skip to content

Rendering of forms and forms submissions fails when wrapped in a virtual page #14165

@Musealali

Description

@Musealali

Written by Muslim Al-Ali Umbraco HQ - feel free to reach out to me anytime for further discussion.

There is currently 2 issues:

  1. Withing a virtual page - if you try to render a forms within an RTE in a content node - it will throw value cannot be null errors in the frontend

image

  1. If you decide to render the forms directly in the view - when you do a form submission you will run into issues with redirect.

image

Seems like forms is not picking up the routes from the virtual page.

Steps to reproduce

Backoffice:

  1. Create 2 document types - a products page (listview) and a product page (should be under the products page)
  2. In the products page documenttype add a SKU textstring and a RTE
  3. Create a root node -> Products and a Product item with a SKU value
  4. Render a form as a macro in the RTE
  5. Then also try to render it directly in the view

Code:

  1. Create a controller that inherits from the UmbracoPageController, IVirtualPageController (I have attached my controller)
  2. Create a get endpoint that gets a specific product by id (Sku)
  3. Implement the findcontent (make sure it finds the root page (products listview page)
  4. Create a ControllerComposer and map the endpoints
  5. Create a TvShow model that inherits from ContentModel

Now try to hit the HttpGet endpoint you created that fetches a product -> you should see the issue.

I have attached my solution to this issue as a reference to re-produce.

(In my solution I use TvShow - you should just use product or w/e you feel like.
FormsVirtualPageIssue.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions