XF 2.0 data-xf-init="field-adder" on numberbox?

Jaxel

Well-known member
Is it possible to use the field-adder function on number boxes?

The problem I am having is that number boxes, instead of being defaulted to "0" when using field-adder, it instead defaults to a blank text box. Which of course returns validation problems when you try to submit the form. Before the form will submit, it will force you to set all number boxes to a number first... since you can't get it to default to "0".
 
It looks like any input values are cleared upon cloning (aside from check-boxes), and there's no way to set a default value for them. You could set required="{{ false }}" on your numberbox, which will allow blank values for all of them (including any added fields). Otherwise you could extend XF.FieldAdder with a wrapper on create() to insert a default value.
 
Back
Top Bottom