Orchard Harvest 2015 – Forms

Dynamic forms are an application of the layouts feature that enables you to build richly laid-out forms, and handle their submission. Sipke, our speaker for this session, is the main developer of both features.

He started by creating a new content submission form, and going through the various options available. Then, he quickly moved on to dropping and configuring title and body fields and associated validation elements onto the design surface. He added a submit button, added the form to navigation, and published it.

A relatively unknown feature of the layout element that Sipke pointed out is keyboard shortcut support to move elements around, with support for cut & paste. This should help with the feature’s accessibility.

Once the form has been published, it is available on the front-end, allowing for end user content submission.

The submitted contents get added to the corresponding list of submissions that is accessible to the site administrators. In order to make things a little more useful, Sipke showed how to use the “create content” option of dynamic forms. In order to make it work, he had to go into the bindings tab of each form field and define what part of the target content type (blog post in the demo) the field should get mapped to.

Because he chose to create blog posts, and blog posts must be contained in a blog, he had to add a new workflow that reacts to the creation of a blog post with a custom activity that can set the container blog.

Once this was done, he was able to create a blog post from the front-end. Of course, in reality, you’d add some validation steps to that workflow, but this is already quite compelling.

Sipke then added a third field to the form for tags, bound to the blog post tags part. To support autocomplete on that new field, he showed how a custom element can easily be implemented to provide a good front-end experience: the blog post editor in the admin dashboard has a user experience that doesn’t immediately translate to the custom form, but it’s relatively easy to create the elements that you’d need to recreate it.

UPDATE: the video is online.

No Comments