Reputation: 45
I am trying to save the value entered by an Author in a NumberField as a 'Long' instead of 'String'. Is there a way to configure this or do I have write something custom?
Upvotes: 0
Views: 2897
Reputation: 71
Add as below for double value and its failing for decimal value i.e. its not allowing decimal values
<price jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/numberfield"
fieldLabel="Product Price"
name="./price"/>
<priceHint jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden"
name="./price@TypeHint"
value="Double"
defaultValue="Double"/>
Upvotes: 1
Reputation: 95
This works fine for me. :)
<noOfViews jcr:primaryType="cq:Widget" fieldLabel="No. of Views" name="./noOfViews" xtype="numberfield"/>
<noOfViewsHint jcr:primaryType="cq:Widget" defaultValue="Long" name="./noOfViews@TypeHint" value="Long" xtype="hidden"/>
Upvotes: 0
Reputation: 3402
You can use TypeHints. Add a hidden field (xtype:hidden) with name = <numberField'sName>@TypeHint and value= Long
Upvotes: 1