Add granite:data to cq dialog textfield

1.6k views Asked by At

I am trying to create a validation function for a textfield depending on the content of other textfield in a cq dialog in AEM 6.5.

I am trying to send within the cq:data the textfield name but I can get AEM to render these data attributes on DOM.

This is a piece of the cq dialog

<creditsTitle
  jcr:primaryType="nt:unstructured"
  sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
  fieldLabel="Credits Title"
  name="./creditsTitle_t"/>
<creditsValue
  jcr:primaryType="nt:unstructured"
  sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
  fieldLabel="Credits"
  validation="custo-validation"
  name="./creditsValue_t">
  <granite:data jcr:primaryType="nt:unstructured"
   dependent-name="creditsTitle_t"/> </creditsValue>

And here is a ss of what gets rendered:

enter image description here

I want to be able to send to the "custo-validation" a parameter with the name of the field that it needs to check,in this case is the one above (creditsTitle_t), but it can be anywhere.

So far the only way I have found is with the granite:data but i can't get it working

1

There are 1 answers

0
Daniel Hernandez On

Your code looks good. just make sure you're adding the granite namespace at the top of the file

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    xmlns:granite="http://www.adobe.com/jcr/granite/1.0"
    sling:resourceType="cq/gui/components/authoring/dialog"
    
    ....