Form design: Custom decimal field forces integers as opposed to others

An end user asked me about a custom decimal field that for some reason only accepts integers even though in schema config it is set as type “BigDecimal” just like adjacent fields that behave differently:

This has me dumbfounded, because I cannot pinpoint any differences between this field and the others that might explain why it forces integers.

					<cell type="label" labelfor="sex"/>
					<cell type="field" id="sex" name="text1" uitype="combobox"/>
					<cell type="label" labelfor="ont"/>
					<cell type="field" id="ont" name="text4" uitype="combobox"/>
					<cell type="label" labelfor="age"/>
					<cell type="field" id="age" name="text2" uitype="text"/>
					<cell type="label" labelfor="rst"/>
					<cell type="field" id="rst" name="text6" uitype="combobox" colspan="3"/>
					<cell type="label" labelfor="wgt"/>
					<cell type="field" id="wgt" name="number1" uitype="text"/>
					<cell type="label" labelfor="bln"/>
					<cell type="field" id="bln" name="number9" uitype="text"/>
					<cell type="label" labelfor="tln"/>
					<cell type="field" id="tln" name="number10" uitype="text"/>
					<cell type="label" labelfor="tlh"/>
					<cell type="field" id="tlh" name="number3" uitype="text"/>

The end user also asked if the field could be changed so that one can choose different units like meters, centimeters or milimeters. Is this even possible at all?

Hi @fedoras,

This issue was identified internally and is caused by the browser assuming the default step value for a numeric input field should be 1 unless otherwise stated. This means that it expects the field to be a whole integer upon initial validation.

I can recreate the issue on my end using v7.9.3.1:

This issue is fixed in version v7.9.4, which will be released very soon.

In the meantime, you should be able to select and deselect the field, and the error will be dismissed. Specify then checks the field and dismisses the browser’s warning. If you are seeing a different behavior, please let me know!

You can also configure the step attribute in the XML form definition to set the precision to override this issue (in Specify 7.7 or newer):

So within the XML for the field:


Thanks for letting me know! This helps.

BTW The end user also asked if the field could be changed so that one can choose different units like meters, centimeters or milimeters using a dropdownlist. Is this even possible at all?

Hi @fedoras,

Unfortunately, this is not possible at this time. The unit can be specified in another text field, such as a pick list to control the allowed terms, but it cannot be stored as metadata in the decimal field itself or indicated in the form definition.