IP validator
miValidatorIp class performs sanity check over computer IP addresses (IPv4). It can be mapped in the data manager, or created runtime.
* Mapped in the data manager class
<?php
class miUserDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormWidgetText',
'data' => 'UserAllowedIp',
'validator' => 'miValidatorIp'
)
);
}
?>
* Created runtime
<?php
class miUserDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormWidgetText',
'data' => 'UserAllowedIp'
)
);
public function initWebForm(miWebForm $form)
{
parent::initWebForm($form);
$validator = new miValidatorIp($form, 'UserAllowedIp');
$form->addValidator('UserAllowedIp', $validator);
}
}
?>