Creating Forms via API

Member since: 2016
 

To help simplify the initial deployment of a site, I'm trying to automate the process of creating a few forms.  I'm finding this process to be rather tedious, and am hoping there is an easier solution.

From what I've read in the documentation (which is extremely limited) and some blog/forum posts, forms are based on the concept of blocks, and can be created as such via IContentRepository.  So long as I put these new instances of FormContainerBlock where Forms is expecting them (ContentReference.GlobalBlockFolder -> "Episerver Forms"), it seems to work as expected.  However, adding fields to the form appears to require creating instances of the FormElement blocks I need (text, number, etc.), and putting them in the "For this block" folder (at least, that appears to be what Forms does out of the box).  I haven't tested this fully yet, but I don't see any reason why it wouldn't work.

Is there a better way to accomplish what I'm trying to do?  It's been basically "guess an check" so far, which is unfortunate and time consuming.  I see the IFormRepository and IFormDataRepository, but they offer very limited funcitonality related to retrieving data from forms/submissions.  If it doesn't already exist, I think having a proper API for interacting with Forms would be very helpful.

Alsothere doesn't appear to be any real "developer documentation" for Forms.  Is this something that is on the roadmap?  Having to dig through source code and random forum posts isn't a very productive way to work...

#190198 Apr 04, 2018 17:35