This extension provides a validator class that enables to define an AR class attribute to be containing a valid class name. This is useful in occasions such as when you have a class file that refers to other models in your system. For example, 'views counter', 'like functionality' and more... .
public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( // more rules here... array('model_name', 'PcClassExistsValidator'), // more rules here... ); }
The following are the class public attributes via which the configuration is passed, along with their default values:
/* @var bool $allowEmpty Whether the attribute is allowed to be empty. */ public $allowEmpty = false; /* @var string $emptyMessage the message to be displayed if an empty value is validated while 'allowEmpty' is false */ public $emptyMessage = "{attribute} cannot be blank"; public $errorMessage = " is not a valid class name. Make sure to configure config/main.php 'import' section to load all relevant classes.";
Be the first person to leave a comment
Please login to leave your comment.