"" value to a field if it is not authored | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
DPrakashRaj
DPrakashRajAccepted solution
New Participant
Mar 10, 2023 7:05 PM UTC

Yes you can use any value even "" as default value with the

<title jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldLabel="Title" name="./title" value=""/>

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/components/coral/foundation/form/textfield/index.html

6 replies

Jagadeesh_Prakash
New Participant
Mar 11, 2023 12:51 PM UTC

@hello299  If none of the mentioned solutions are not working. Write a script which will set the value to "" 

 

if (isEmpty(value)) {
return '"';
}

Translate
SantoshSai
New Participant
Mar 11, 2023 4:15 AM UTC

Hi @hello299 ,

Yes! You can achieve that, kindly refer below snippet.

 

<demo jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldLabel="Demo" name="./demo" value="&quot;&quot;"/>

 

This will help you to pre-set value in dialog, additionally you can set it in many different way eg.

  • cq:template
  • Sling Model

Hope that helps!

Regards,

Santosh

Translate
Santosh Sai
DPrakashRaj
DPrakashRajAccepted solution
New Participant
Mar 10, 2023 7:05 PM UTC

Yes you can use any value even "" as default value with the

<title jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldLabel="Title" name="./title" value=""/>

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/components/coral/foundation/form/textfield/index.html

Translate
Rohit_Utreja
New Participant
Mar 10, 2023 4:10 PM UTC

@hello299 ,
Could you please share the use-case for this scenario?

Translate
hello299Author
Level 2
Mar 10, 2023 5:34 PM UTC

How can we set default value as "" to a textfield?

Translate
Rohit_Utreja
New Participant
Mar 11, 2023 6:57 PM UTC

Hi @hello299 

 

Default value can be set in the textfield node by setting a property value as "".

You can check the details of all supported properties at "/libs/granite/ui/components/coral/foundation/form/textfield/render.jsp".

 

I hope, it helps.

Thanks

Translate