In the component cq:dialog, I want to fetch the value of a dropdown field and store it into another dialog field node.
For example :
<content-type
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
fieldDescription="Content Type for content"
name="./jcr:content/metadata/content-type"
multiple="{Boolean}true"
granite:id="seeAlso"
fieldLabel="Content Type">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="project/utilities/dialog/datasource"
dataType="content-type"
sort="{Boolean}true"
path="/content/project/global/reference-data/metadata/content-type"/>
</content-type>
<usedIn-container
granite:id="seeAlso"
jcr:primaryType="nt:unstructured"
jcr:title="Select to include"
sling:resourceType="granite/ui/components/coral/foundation/form/fieldset"
bottomDescription="select as required">
<items jcr:primaryType="nt:unstructured">
<header
jcr:primaryType="nt:unstructured"
sling:resourceType="project/components/commons/see-also/note"
note="Title|Content ID|Topic Path|Last Published Date"/>
<used-in
jcr:primaryType="nt:unstructured"
sling:resourceType="dam/gui/components/admin/schemafield"
fieldLabel="Used In"
name="./jcr:content/metadata/usedIn"
contentType=*here I want to store value of above content type dropdown*
resourceType="project/components/commons/see-also/checkboxgroup">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/bin/project/getTopicReferences"/>
</used-in>
</items>
</usedIn-container>
In above component xml, I want to store value of dropdown content-type in used-in node.
I want to know if there exists an OOTB way to do this within the xml.
I am not looking for solutions via javascript.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
You need to try like below
Field from where the value needs to be copied
Field where the value needs to be copied
corresponding hidden field for @valueFrom
After saving the dialog
opening the dialog
@pulkitvashisth : It is possible to do so using @ValueFrom suffix. This is definitely possible for simpler fields, please try it for your use-case of drop-down fields and see if t works there as well.
Please refer these links:
@Kamal_Kishor I checked with @ValueFrom
But it doesn't seem to work.
Below is the code for the same.
<used-in
jcr:primaryType="nt:unstructured"
sling:resourceType="dam/gui/components/admin/schemafield"
fieldLabel="Used In"
name="./jcr:content/metadata/usedIn"
contentType="./jcr:content/metadata/contentType@ValueFrom"
resourceType="project/components/commons/see-also/checkboxgroup">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/bin/project/getTopicReferences"/>
</used-in>
I also tried with
@pulkitvashisth : @ValueFrom has to be applied in name field.
Something like this for example:
<field1
.....
fieldLabel="Field 1"
name="./field1"/>
<field2
.....
name="./field2@ValueFrom"
value="./field1"
defaultValue="./field1"/>
This will store the value from 'field1' in 'field2' when you save the component dialog.
You can try with simple textfield first to see that it works. Later you can try it with drop-down field values. Also, don't skip the defaultValue as that seems to be required (you can try with and without it to see quickly).
You need to try like below
Field from where the value needs to be copied
Field where the value needs to be copied
corresponding hidden field for @valueFrom
After saving the dialog
opening the dialog
No, there is no out-of-the-box way to do that as far as i know (i might be wrong).
All the information from the dialog is only available in the FrontEnd until you submit it. After this, the information gets stored in nodes. So, if you need to use the data which is not yet stored in JCR, you need to use JavaScript to accommodate your other dialogs' components.
This approach is usually used to hide/show other elements or to populate other dropdowns. You can check references here:
Hope this helps.