Form Editor is meant to be used just like any other Umbraco property editor: In the context of one specific page. However, in some cases you might want to reuse a form across multiple pages, and of course you can do that as well.
First of all you need a form and some pages that will contain the form. Usually you'll create the form in a content folder outside of your site structure - something like this:
- Front Page
- Page 01
- Page 02
- Forms Folder
- My Reusable Form
Now add a content picker to the page content type and select My Reusable Form on the pages where you want to display the form. In the following, the content picker property is assumed to have the alias formContentPicker
.
Once you've got the content all set up, you'll need to tell the Form Editor to use selected content (My Reusable Form) instead of the currently requested content. This is done by assigning the selected content to ViewBag.FormContent
before calling the partial view that renders the form.
The sample templates have already been prepared for this.
// get the selected content that contains the form model
var formContentId = Model.Content.GetPropertyValue<int>("formContentPicker");
var formContent = Umbraco.TypedContent(formContentId);
// assign the selected content to ViewBag.FormContent
ViewBag.FormContent = formContent;
That's it - you're good to go.
Onwards to multiple forms per page.