Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

dialog : set value if not set on submit

Anonymous
Not applicable

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.

1 Accepted Solution
edubey
Correct answer by
Level 10
Level 10

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-dia...

Code will be similar to 

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

View solution in original post

2 Replies
edubey
Correct answer by
Level 10
Level 10

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-dia...

Code will be similar to 

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