Decimal validator
miValidatorDecimal class performs sanity check over two digit precision decimal numbers. It can be mapped in the data manager, or created runtime.
* Mapped in the data manager class
<?php
class miOrderDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormWidgetText',
'data' => 'OrderTotal',
'validator' => 'miValidatorDecimal'
)
);
}
?>
* Created runtime
<?php
class miOrderDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormWidgetText',
'data' => 'OrderTotal'
)
);
public function initWebForm(miWebForm $form)
{
parent::initWebForm($form);
$validator = new miValidatorDecimal($form, 'OrderTotal');
$form->addValidator('OrderTotal', $validator);
}
}
?>
* Valid decimal numbers:
1234567890.01
155.00
135.57
* Invalid decimal numbers:
12345678901.01
155.0
135.570