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

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

  • June 6, 2016
  • 13 replies
  • 7090 views

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.
Best answer by askdctm

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

askdctmAuthor
New Participant
June 7, 2016

Hi Kunal/Kautuk,

Thank you for your reply.

#1]Currently I want to limit the tags selected in that field to 3, irrespective of the namespaces they belong to. Tried with the below, but its not working and the tag field shows up blank.

<tags
                        jcr:primaryType="cq:Widget"
                        allowBlank="false"
                        cls="cq-propsdialog-tags"
                        fieldLabel="Tags"
                        name="./cq:tags"
                        xtype="tags">
                        <namespaces jcr:primaryType="cq:WidgetCollection">
                            <mycrxsample
                                jcr:primaryType="nt:unstructured"
                                maximum="3"
                                name="mycrxsample"/>
                        </namespaces>
                    </tags>

kautuk_sahni
Employee
June 7, 2016

Hi Please have a look at this old post:- https://forums.adobe.com/thread/1175413

//

<locationTag jcr:primaryType="cq:Widget" allowBlank="{Boolean}false"  
       cls="cq-propsdialog-tags" fieldLabel="Campus Location"  
       fieldDescription="Specify a campus location" name="./locationID/cq:tags"  
                                                  xtype="tags">  
       <namespaces jcr:primaryType="cq:WidgetCollection">  
            <ns1 jcr:primaryType="nt:unstructured" maximum="1"  name="campuses" />  
       </namespaces>  
  </locationTag>  

 

The configuration (if used in the complex format) actually expects a nested structure of JCR nodes. Therefore, in my dialog.xml I needed an additional node:

<tags
  jcr:primaryType="cq:Widget"
  allowBlank="true"
  fieldLabel="Tags"
  name="./tags"
  xtype="tags">
    <namespaces jcr:primaryType="cq:WidgetCollection">
        <topics jcr:primaryType="nt:unstructured" maximum="1" name="topics" />
    </namespaces>
</tags>

Link:- http://stackoverflow.com/questions/37661502/trouble-limiting-the-number-of-tags-in-a-taginputfield

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
Kunal_Gaba_
New Participant
June 6, 2016
<tagsjcr:primaryType="cq:Widget"fieldLabel="Tags"name="./tags"xtype="tags"><namespaces jcr:primaryType="cq:WidgetCollection"><topic1 jcr:primaryType="nt:unstructured" maximum="3" name="topic1" />        <topic2 jcr:primaryType="nt:unstructured" maximum="3" name="topic2" />
</namespaces></tags>

 

Ref- http://mspbox.blogspot.com/2014/09/limit-tags-selection-to-certian-number.html