Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 506

Warning: Incorrect key file for table './miphpf_miphpfcom/watchdog.MYI'; try to repair it query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.', 2, '', 'http://www.miphpf.com/manual/unique_validator.html', '', '3.148.107.246', 1734785620) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Unique validator | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Unique validator

: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.

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);
    }
}
?>