How to restrict number of tags we are able to select in the component dialog | Community
Skip to main content
Level 9
June 6, 2016
Solved

How to restrict number of tags we are able to select in the component dialog

Hi All,

In our component dialog.xml, we currently have the below :

<tags
                    jcr:primaryType="cq:Widget"
                    cls="cq-propsdialog-tags"
                    fieldLabel="Tags"
                    name="./cq:tags"
                    xtype="tags"/>

#1] We should be able to restrict the tags we are able to select in the dialog to 3. Saw a similar article https://forums.adobe.com/thread/1175413, but on trying that , it doesn't seem to be working correctly.

#2] Also, an additional query : what should be done if we have to restrict 3 tags per namespace.

if you can let me know the changes that have to be made to the dialog structure/reference articles, it would be helpful.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
askdctmAccepted solution
Level 9
June 12, 2016

Hi All, 

Tried writing a listener making use of addtag() event in Tagfield, but it is failing in all scenarios except one. Basically, is of no use in real world-scenarios.

Any snippet/reference would be helpful.

13 replies

kautuk_sahni
Employee
June 13, 2016

askdctm wrote...

Hi Kautuk,

Phewwww. At last able to get it to work. Thanks a ton :)

 

Excellent!!

Please share a solution with small code for communities benefit.

 

Thanks and Regards

Kautuk Sahni  

Translate
Kautuk Sahni
askdctmAuthor
Level 9
June 13, 2016

Hi Kautuk,

Phewwww. At last able to get it to work. Thanks a ton :)

Translate
kautuk_sahni
Employee
June 13, 2016

Hi

The internal team has said that you need to write a custom validator to do the needful.

Reference article shared are:-

Link 1:- http://experience-aem.blogspot.in/2016/06/aem-62-touch-ui-validator-for-restricting-tag-count-dialog-field.html [Touch UI]

Link 2:- http://experience-aem.blogspot.in/2016/06/aem-61-classic-ui-limit-number-of-tags-selected-xtype-tags-widget.html [Classic UI]

I hope this would help you.

 

Thanks and Regards

Kautuk Sahni

Translate
Kautuk Sahni
askdctmAuthorAccepted solution
Level 9
June 12, 2016

Hi All, 

Tried writing a listener making use of addtag() event in Tagfield, but it is failing in all scenarios except one. Basically, is of no use in real world-scenarios.

Any snippet/reference would be helpful.

Translate
askdctmAuthor
Level 9
June 11, 2016

Hi All,

If anyone has implemented such a use case, it would be helpful if you can share snippet on this. 

Translate
askdctmAuthor
Level 9
June 10, 2016

Hi Kautuk,

Thank you for your reply.

Translate
kautuk_sahni
Employee
June 10, 2016

I have asked internally, i will share their response soon.

Thanks and Regards

Kautuk Sahni

Translate
Kautuk Sahni
askdctmAuthor
Level 9
June 10, 2016

Hi Scott,

Thank you for your reply.

Since the article in http://mspbox.blogspot.com/2014/09/limit-tags-selection-to-certian-number.html mentioned about restricting tags in AEM 6.0, thought of trying on the similar lines. 

Also, not sure how is it working , based on the article. Thought can tweak it to meet my objective.

Translate
smacdonald2008
Level 10
June 9, 2016

The Tags Xtype does not support a field that you can set to limit the number of tags you can find:

https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.tagging.TagInputField

You will have to write custom xtype using this data type. You can add custom logic to control the number of tags selected. 

Fort example -- you can use the addtag event to handle a counter. Each time a tag is selected - you can increment an index that controls the number of tags you can add. This is the only way i can see. 

Now if you  to query tags - use backend Java logic to query the tags selected by the dialog. You can use the tag manager API: 

https://helpx.adobe.com/experience-manager/using/customtags1.html

Translate
askdctmAuthor
Level 9
June 9, 2016

Hi All,

I am still not able to get this to work.

I want to restrict the total number of tags to 3 in my component tag field, irrespective of the namespaces they are coming from.

Any additional thoughts/snippet on this will be helpful.

Translate