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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

AEM Number Field with decimal value as Zero

Avatar

Level 2

Hi,

 

While authoring AEM dialog with number field, The decimal values it's rounding off... only If the decimal value is "zero"

Ex: if we enter 13.0 rounding off to 13

13.00 rounding off to 13

 

Is it possible to keep the same value(Whatever authored) as 13.0/13.00 instead of 13 using the number field? 

0 Replies

Avatar

Community Advisor

Try using typeHint. Add a hidden field with name = <numberField'sName>@TypeHint and value= Long

 

Also check this post https://www.argildx.com/technology/how-to-change-data-type-typecast-in-aem-use-typehint/

Avatar

Level 5

Hi @vasgurug ,

 

Which version of coral you are using. Please use below as sling:resourceType in dailog. Then it will work as expected .

 

Capture.PNGgranite/ui/components/coral/foundation/form/numberfield.

 

To work with Coral UI-2. please step property as below.

Capture.PNG

Thanks,

Sandeep.

 

Avatar

Level 2
With Coral it's holding the value but we are still using the granite(granite/ui/components/foundation/form/numberfield) … Is there any way

Avatar

Administrator
@Sandeep6, good to see you back in the AEM community. Community need SMEs like you. Keep helping other.

Avatar

Level 2

@Sandeep6 @Bhuwan_B 

 

If we try using the below way it's worked using coral UI-3(granite/ui/components/coral/foundation/form/numberfield)

 

But not working with AEM 6.4 and if we use Coral UI-2 (granite/ui/components/foundation/form/numberfield) 

let me know if there is a way in Coral UI-2 ?

 

Avatar

Community Advisor

Hi @vasgurug 

Suggested to use coral 3 widget(s) (granite/ui/components/coral/foundation/form/numberfield), if you want to get is work with coral 2 widget parse the value to Double while rendering, coral 2 widget trims .0 on field blur.

-AG

Avatar

Level 2
Thanks. I am looking for solution to hold the value at widget (dialog) level while authoring entering decimal value with .00

Avatar

Community Advisor

@vasgurug 

Use the following properties

sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"
step="any"
min="0"
typeHint="double"

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now