Expand my Community achievements bar.

SOLVED

dialog : set value if not set on submit

Avatar

Former Community Member

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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"); }

Avatar

Former Community Member
This component cnfiguration solved my case <vocLevel        jcr:primaryType="cq:Widget"        emptyText="{String}N/A"        fieldLabel="VOC Level"        name="./vocLevel"        xtype="textfield"        />