Nested Multifield or Multifield with in Multifield in CQ5

2.8k views Asked by At

Wanted to a build a nested multifield dialogue in cq5.

My requirement is to build a single multified component with

Title

LinkText

Linkpath

ImageUpload

with in this multifield ,I wanted to have linktext as another multifield.

Note:

.I was able to create titile,linktext,linkpath,imageupload as multifield,but couldnt make linktext as another multifield inside a multifield. I am new to cq5 dev,Kinldy Suggest if there are any other approach.

3

There are 3 answers

1
Chris Leggett On

I believe the only way to do this is to write your own widget. I have accomplished this but am unable to share the code. If you want you can check out this open source library I have been working on building out at https://github.com/Velir/AEM-Toolbox. The StucturedMultiList widget may suit your needs.

0
Chris Tompkinson On

An example how to implement a custom widget as described by Chris Leggett can be found at:

http://cq.shishank.info/2011/12/19/multifield-with-custom-xtype/

How I've stored the value is in the format:

[item1|item2]

Using a bit of logic you can then extract a link text and url but the third value seems to step into bad practice if you're using this format, but the style of storing this information will be the same. Maybe you could store the information as JSON, but I haven't personally seen an implementation of this.

Hope that helps.

0
Sharath Madappa On

This will involve customizing the multifield js and creating custom xtypes by extending composite field. Most of the part of nesting custom multifields is same as creating a single custom multifield.

The inner multifield will return a comma separated String on getValue, this will have to be concatenated with other fields of outer multifield separated by a delimiter. The set value of inner multifield will expect a string array, for this you will have to modify the multifield js of inner multifield and override the set value method to take the comma separated string and split into an array.

The outer multifield will also have to be updated on change of inner multifield content.This can be done by calling the update method right after updating inner multifield(reference to the outer multifield can be obtained through findParentBy method)

The end result will look like this

String array

[0] : a-outer-field1<#->a-outer-field2<#->a-1-inner-field1<#-#>a-1-inner-field2<#-#>,a-2-innerfield1<#-#>a-2-innerfield2<#-#><#-*>

[1] : b-outer-field1<#->b-outer-field2<#->b-1-inner-field1<#-#>b-1-innerfield2<#-#>,b-2-innerfield1<#-#>b-2-innerfield2<#-#><#-*>

Check out this link http://cq5tutorials.blogspot.com/2014/04/cq5-multifield-in-multifield.html