Url validator
miValidatorHttp class performs sanity check over url addresses. 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' => 'UserWebSiteAddress',
'validator' => 'miValidatorHttp'
)
);
}
?>
* Created runtime
<?php
class miUserDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormWidgetText',
'data' => 'UserWebSiteAddress'
)
);
public function initWebForm(miWebForm $form)
{
parent::initWebForm($form);
$validator = new miValidatorHttp($form, 'UserWebSiteAddress');
$form->addValidator('UserWebSiteAddress', $validator);
}
}
?>
* Valid url addresses:
http://87.14.20.231
http://www.google.com
http://something.com
* Invalid url addresses:
ftp://87.14.20.231
file:///index.html
www.google.com