Expand my Community achievements bar.

SOLVED

Show value in coral textfield only once

Avatar

Community Advisor

Hi,

 

I want to show the value in a Coral Text field only for the first time when the component is dropped and author opens the dialog. After first submit it should hold the value that has been authored in the dialog(any value or EMPTY).

Currently I am using value property to textfield and the behaviour is, if the author empty the field value and submit the dialog, on dialog re-open the filed is being populated with value that has been set in dialog properties. 

 

Is there a way that we can set the default value only once for the first time? I don't see the defaultValue property in the documentation.

TextField — Granite UI 1.0 documentation

Field — Granite UI 1.0 documentation

 

Thank you.

 

-AG

1 Accepted Solution

Avatar

Correct answer by
Level 8

@Anudeep_Garnepudi 

value property added to dialog textfield provides default value, when author open dialog

 

1. If author empty the default value added & submit dialog then the field value will be posted & stores as blank. if author reopens the dialog then author will see empty value.

2. If author leaves default value as is & submit dialog then default value will be posted & stored. if author reopens the dialog then author will see default value prepopulated.

 

There will be no possibility that author remove/empty the default value, submit & then when author reopens the dialog its prepopulating the default value again.

 

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

 

View solution in original post

7 Replies

Avatar

Correct answer by
Level 8

@Anudeep_Garnepudi 

value property added to dialog textfield provides default value, when author open dialog

 

1. If author empty the default value added & submit dialog then the field value will be posted & stores as blank. if author reopens the dialog then author will see empty value.

2. If author leaves default value as is & submit dialog then default value will be posted & stored. if author reopens the dialog then author will see default value prepopulated.

 

There will be no possibility that author remove/empty the default value, submit & then when author reopens the dialog its prepopulating the default value again.

 

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

 

Avatar

Community Advisor

Hi @Manjunath_K,

 

My dialog field configuration is exactly same as you mentioned. If author empty the field the property will be deleted from the content node, it won't be saved as a empty value unless we specify blank space.

Avatar

Level 8

@Anudeep_Garnepudi 

As per my understanding your requirement is "there should default value, when author open dialog & submit dialog without removing default value. expected result is blank value should be stored in node instead of default value". then you are expecting placeholder here not the default value. for that i will suggest to use "emptyText" property (as mentioned below), this property value will not be posted as dialog field value & it will work same as how we have html form input placeholder.

 

 

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

 

Avatar

Community Advisor
@Manjunath_K, emptyText is a placeholder text. What I need is default value. The value property is working fine until we empty the field and submit. If I empty the default value and submit the dialog upon re-open it should be blank, but it is populating the value from configuration.

Avatar

Level 8

@Anudeep_Garnepudi 

your last comment is creating confusion here, if we remove default value, submit dialog & then reopen dialog then there is no chance it will show default value again because in previous dialog submit blank value will be posted & stored for the input attribute in nodes. 

 

"If I empty the default value and submit the dialog upon re-open it should be blank, but it is populating the value from configuration."

Avatar

Community Advisor
@Manjunath_K, thanks for your time. I figured out the root cause. The customization causing the issue, I thought the issue after migrating to 6.5. Thank you