Jump to content

Wish: Default value for Decimal field type


HMCB
 Share

Recommended Posts

Unlike the Integer input type, Decimal doesn’t allow for a default value. I’d love to see this added.

I’m working on a mini project where this would come in really handy. The site admins would have all 7 fields pre-populated and they can then adjust as needed.

  • Like 2
Link to comment
Share on other sites

  • 9 months later...

Hi @HMCB

Currently it is not so easy to provide an default value option for number fieldtypes other than Integer, because all core number Inputfieldtypes using the same rendering function: InputfieldInteger::render(), converting any init or default value to int. So currently there is no option to define default values with decimal places.

The core InputfieldFloat and / or InputfieldInteger needs an update to allow default values with decimals. In a second step number fieldtypes could include an option to define a default value.

I wrote a Module as a workaround until the core issues are fixed.

https://github.com/kixe/FieldtypeDecimalPlusDefault

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...