dialog : set value if not set on submit | Community
Skip to main content
October 16, 2015
Solved

dialog : set value if not set on submit

  • October 16, 2015
  • 2 replies
  • 1649 views

Hi

I have the following textfield:
<vocLevel

        jcr:primaryType="cq:Widget"        value="{String}N/A"        defaultValue="{String}N/A"        fieldLabel="VOC Level"        name="./vocLevel"        xtype="textfield"        />

If field's value is removed by conent author, how to populated it with 'N/A' value after content author submits dialog?

Thank you in advance.

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 edubey

You can use a listeners "loadcontent", which will execute when dialog is open. In that listener you can write js code to check if value is "" (empty) , the set the value to "N/A".

Help link: https://myprogressivelearning.wordpress.com/2015/01/21/setting-default-value-to-the-drop-down-of-dialog-in-adobe-aem-cq5/

Code will be similar to 

function(dialog){ x= dialog.findParentByType('dialog').getField('./vocLevel'); if(x.getValue()=="") x.setValue("N/A"); }

2 replies

edubey
edubeyAccepted solution
New Participant
October 16, 2015

You can use a listeners "loadcontent", which will execute when dialog is open. In that listener you can write js code to check if value is "" (empty) , the set the value to "N/A".

Help link: https://myprogressivelearning.wordpress.com/2015/01/21/setting-default-value-to-the-drop-down-of-dialog-in-adobe-aem-cq5/

Code will be similar to 

function(dialog){ x= dialog.findParentByType('dialog').getField('./vocLevel'); if(x.getValue()=="") x.setValue("N/A"); }
October 16, 2015
This component cnfiguration solved my case <vocLevel        jcr:primaryType="cq:Widget"        emptyText="{String}N/A"        fieldLabel="VOC Level"        name="./vocLevel"        xtype="textfield"        />