Unique validator
miValidatorUnique class performs sanity check over unique database fields. It CAN'T be mapped in the data manager. Only runtime creation is allowed. This validator is used when a unique field is allowed in the database column, for example when user e-mail is collected or for user login names.
* Create runtime
<?php
class miUserDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormWidgetText',
'data' => 'UserLoginName'
)
);
public function initWebForm(miWebForm $form)
{
parent::initWebForm($form);
$record = new miSqlRecord('Users', 'UserID');
// Unique validator can be created only at runtime because requires additional parameters
$validator = new miValidatorUnique($form, 'UserLoginName', $record);
$form->addValidator('UserLoginName', $validator);
}
}
?>