Expand my Community achievements bar.

SOLVED

AEM Forms - Fragment Override Settings

Avatar

Level 7

Hi,

I am designing a forms implementation where we want to configure fields (such as an email address) once and share them across multiple forms.

The reason for this, is to control the functionality of fields (validation, max characters, consistent dropdown options ) etc, but allow authors to create forms using these pre-prepared fields. Fragments are (nearly) perfect for this, however there is one short coming that I need a solution for.

I want to be able to vary certain settings on a per form basis.

Let's focus on one attribute for now, the "title" which is used as the label for the field.

The fragment settings for the email address title is "Email Address"

On form A - I would like the title to be "Contact Email Address"

On form B - I would like the title to be "Business Email Address"

I have overridden the guideField and figured I could lookup the container (the fragment panel) and use the title from that.

However, the parent of the field when it is being rendered is the fragment rootpanel and not the target form where the fragment is used (e.g. Form A and Form B).

Is there an alternative solution to override the title on a form by form basis? I could use cq:templates to define the fields however once the forms are authored any changes would have to be made across all forms (not centrally).

Is there perhaps a different way to centrally store settings for a field with the ability to override values?

Thanks,

James

1 Accepted Solution

Avatar

Correct answer by
Level 7

I created a solution to this problem:

  • I overrode the panel component
  • In the panel.jsp before the fragRef is included - I set a flag on the request to signify that the request is coming via a fragment.
  • Then on my guidefield label (also overridden) I call a java class which:

- if the flag is set -  uses the request origin (from getRequestURI) to apply any overrides.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

I created a solution to this problem:

  • I overrode the panel component
  • In the panel.jsp before the fragRef is included - I set a flag on the request to signify that the request is coming via a fragment.
  • Then on my guidefield label (also overridden) I call a java class which:

- if the flag is set -  uses the request origin (from getRequestURI) to apply any overrides.