You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.5 KiB
67 lines
1.5 KiB
11 years ago
|
<?php
|
||
|
|
||
11 years ago
|
namespace yiiunit\data\validators\models;
|
||
11 years ago
|
|
||
11 years ago
|
use yii\base\Model;
|
||
|
|
||
|
class FakedValidationModel extends Model
|
||
11 years ago
|
{
|
||
11 years ago
|
public $val_attr_a;
|
||
|
public $val_attr_b;
|
||
|
public $val_attr_c;
|
||
|
public $val_attr_d;
|
||
|
private $attr = [];
|
||
11 years ago
|
|
||
11 years ago
|
/**
|
||
|
* @param array $attributes
|
||
|
* @return self
|
||
|
*/
|
||
|
public static function createWithAttributes($attributes = [])
|
||
|
{
|
||
|
$m = new static();
|
||
|
foreach ($attributes as $attribute => $value) {
|
||
|
$m->$attribute = $value;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
return $m;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['val_attr_a', 'val_attr_b'], 'required', 'on' => 'reqTest'],
|
||
|
['val_attr_c', 'integer'],
|
||
10 years ago
|
['attr_images', 'file', 'maxFiles' => 3, 'extensions' => ['png'], 'on' => 'validateMultipleFiles', 'checkExtensionByMimeType' => false],
|
||
|
['attr_image', 'file', 'extensions' => ['png'], 'on' => 'validateFile', 'checkExtensionByMimeType' => false]
|
||
11 years ago
|
];
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public function inlineVal($attribute, $params = [])
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public function __get($name)
|
||
|
{
|
||
|
if (stripos($name, 'attr') === 0) {
|
||
|
return isset($this->attr[$name]) ? $this->attr[$name] : null;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
return parent::__get($name);
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public function __set($name, $value)
|
||
|
{
|
||
|
if (stripos($name, 'attr') === 0) {
|
||
|
$this->attr[$name] = $value;
|
||
|
} else {
|
||
|
parent::__set($name, $value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getAttributeLabel($attr)
|
||
|
{
|
||
|
return $attr;
|
||
|
}
|
||
11 years ago
|
}
|