To the dialog of a custom submit action I want to add a dropdown that gets its options dynamically from a javascript function.
The xml for the dialog item is:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Widget" name="...." fieldLabel="...." fieldDescription="...." allowBlank="true" type="select" xtype="selection" optionsProvider="function() { return [{value:'1',text:'One'},{value:'2',text:'Two'}];}"/>
This does not work!
But the variant below works:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Widget" name="..." fieldLabel="..." fieldDescription="..." allowBlank="true" type="select" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <one jcr:primaryType="nt:unstructured" text="One" value="1" /> <two jcr:primaryType="nt:unstructured" text="Two" value="2" /> </options> </jcr:root>
I have no clue why the first configuration is not working. 'optionsProvider' is a configuration option documented at http://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html.
Can somebody explain why the first configuration is not working?
Solved! Go to Solution.
Views
Replies
Total Likes
I've found a working solution on my own:
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Widget" name="PROPERTY-NAME" fieldLabel="FIELD-LABEL" fieldDescription="..." type="select" xtype="selection" allowBlank="true"> <listeners jcr:primaryType="nt:unstructured" beforerender="function(){this.setOptions([{value:"1",text:"one"},{value:"2",text:"two"}])}"/></jcr:root> </jcr:root>
This is the configuration of a drop down list labeled as 'FIELD-LABEL' with two items 'one' and 'two'. The value either '1' or '2' of the selected item will be reflected in the property 'PROPERTY-NAME' among the submitted properties.
I've found a working solution on my own:
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Widget" name="PROPERTY-NAME" fieldLabel="FIELD-LABEL" fieldDescription="..." type="select" xtype="selection" allowBlank="true"> <listeners jcr:primaryType="nt:unstructured" beforerender="function(){this.setOptions([{value:"1",text:"one"},{value:"2",text:"two"}])}"/></jcr:root> </jcr:root>
This is the configuration of a drop down list labeled as 'FIELD-LABEL' with two items 'one' and 'two'. The value either '1' or '2' of the selected item will be reflected in the property 'PROPERTY-NAME' among the submitted properties.
Views
Likes
Replies