When using live inputs we need to have the following option types on our section: L ,
When using number fields it is important to set inputType as "number" and 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'=>'live', //required 'inputType' =>'number', //required 'label'=>'Amount', //required 'name' => 'cost', //required (column name) 'attributes'=> 'min="0" step=".01"', //this allows 2 decimals (9.99) 'value' => '' //optional, it can be left empty or add the value from the database 'ID'=>'amount_to_pay', //optional, name is used by default 'encdata'=>[ //optional unless $dbtable, $idfield and $idvalue are not declared, 'TYPE' =>'LIVE', 'DBTABLE' =>$dbtable, 'IDFIELD' =>$idfield, 'IDVALUE' =>$idvalue ], callback => 'location.reload()' //optional ]);
For Integers:
If we only want to allow integers step should be equal to 1 and to prevent decimals add the following JS to the attributes: onkeypress="return event.charCode >= 48 && event.charCode <= 57"
addField([ 'type'=>'live', //required 'inputType' =>'number', //required 'label'=>'Amount', //required 'name' => 'cost', //required (column name) 'attributes'=> 'min="0" step="1" onkeypress="return event.charCode >= 48 && event.charCode <= 57"', //this doesn't allow decimals 'value' => '' //optional, it can be left empty or add the value from the database 'ID'=>'amount_to_pay', //optional, name is used by default 'encdata'=>[ //optional unless $dbtable, $idfield and $idvalue are not declared, 'TYPE' =>'LIVE', 'DBTABLE' =>$dbtable, 'IDFIELD' =>$idfield, 'IDVALUE' =>$idvalue ] ]);