How Fragments Can Further Your Modular Form Design

Part Four in a Series on Modular Form Design

21-12-2021
Angèle Taylor

We have looked out how we can separate out structural pieces of a form as well as the look and feel for a form. Today I would like to explore how we can separate specific pieces of content by leveraging fragments.

Fragments are referable pieces of content that are dynamically loaded every time a form renders. This ensures that the most recent version of the content is always being shown at the time of use just as structural elements of a template or the theme is loaded. Through this live connection we can extract sections that are shared amongst other forms.

Further to this we can pull specific content that is owned or managed by a different area out of the actual form itself. This allows the owner of the content to be able to manage the specific text rather than relying on the form creator to ensure that the text is as it should be. Legal teams and content matter experts can control the verbiage, while form creators can focus on the functionality of the form.

Another use for fragments is reusable grouping of fields. These fields are always required together and always appear in the same order with the same expected behaviour; a common example could be an address block. Rather than having to manually add in a field for country, state/province, city... we can instead group these elements together into a fragment which only require one element to be added to the form, the address block. Just as we saw with separating text, we now have a definition for an address block that can be added to forms quickly and if a change needs to be made only one location would need to be updated to propagate the change.

Using this methodology is also suggested when adding specific repeatable behaviours are required. Sometimes more complex logic is required for specific sections of a form. When this happens and the section is used in other forms it is suggested to build the section as a fragment. This means your technical team would be building out the logic once and then allowing business users to simply add in the fragment where it is needed without having to worry about the logic.

Identifying which chunks of content should be created can be an exercise but will give your authors a library of content that they can use to quickly build out new content. Having a central location to be able to make changes streamlines the process for making changes and building logic into the fragments empowers business users to add complex logic into their form without having to lean on IT every time. Lastly allowing content owners to manage their specific content elevates pressure on the content creators and streamlines the process for content changes while ensuring all team members are getting what they require.