umbraco/The-Starter-Kit

The Umbraco Form needs to be created with a package action - it cannot just be included as a json file

Closed this issue · 1 comments

Currently the way that the Contact Forms is being installed is that it's json file is simply included in the package manifest, example:

<file>
    <guid>adf160f1-39f5-44c0-b01d-9e2da32bf093.json</guid>
    <orgPath>/App_Data/UmbracoForms/Data/forms</orgPath>
    <orgName>adf160f1-39f5-44c0-b01d-9e2da32bf093.json</orgName>
</file>

This works for a normal install but the problem is that this doesn't work for Umbraco Cloud since no UDA file is ever created for this form. A Form is like a schema item in Umbraco Cloud, it's UDA file is committed to Git and deployed via Git. If i clone an empty UC site, install this starter kit and then push it up, the form will not be installed because there is no UDA file. If the form was created with APIs during package installation a UDA file would be created because it would trigger event handlers.

Forms stores it's data in App_Data - it should be in the database but that's something we need to do in the next major version. In the meantime, files in App_Data can be thought of as a database, these files don't get persisted to Git.

But we would also have a chicken/egg problem with trying to do this too since Forms isn't actually installed when the package is installed and therefore no APIs can be used.
Instead we could do this in the Umbraco.SampleSite.UmbracoEvents.InstalledPackage_AfterSave but we'd have to use reflection or dynamics to do it since Umbraco forms code cannot be referenced.