Number Inputs

Create Inputs of type number

Just as the text field we will use the same parameters, but the type will be "number" and it is important to add a few attributes, like step and min. Step allows decimals, in the following example 2 decimals, one decimal at a time. 

For Decimals

addField([
   'type'=>'number', //required
   'attributes'=>'min="0" step=".01"', //optional
   'name'=>'', //optional (leave empty if you don't want to submit the value)
   'value'=>'',  //optional (predefined value)
   'placeholder'=>'', //optional
   'label'=>'Information Text', //required
   'id'=>'', //optional (name becomes the id by default)
   'style'=>'', //optional
   'class'=>'', //optional
   'blockClass'=>'', //optional (class for the container)
   'blockStyle'=>'', //optional (style for the container)
   'dataString'=>'data-test="value"', //optional (full data attribute and value)
]);

 

For Integers

For integers use step=1 and validate the value on the server. Browser constraints do not replace server validation.

addField([
   'type'=>'number', //required
   'attributes'=>'min="0" step="1"', //optional
   'name'=>'', //optional (leave empty if you don't want to submit the value)
   'value'=>'',  //optional (predefined value)
   'placeholder'=>'', //optional
   'label'=>'Information Text', //required
   'id'=>'', //optional (name becomes the id by default)
   'style'=>'', //optional
   'class'=>'', //optional
   'blockClass'=>'', //optional (class for the container)
   'blockStyle'=>'', //optional (style for the container)
   'dataString'=>'data-test="value"', //optional (full data attribute and value)
]);

 

Quick Mode: 

addField('number:min="0" step=".01"', 'Label', 'DB Column Name','Input Value');