mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
renamed $object to $model
This commit is contained in:
@ -166,12 +166,12 @@ class FileValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function validateAttribute($object, $attribute)
|
||||
public function validateAttribute($model, $attribute)
|
||||
{
|
||||
if ($this->maxFiles > 1) {
|
||||
$files = $object->$attribute;
|
||||
$files = $model->$attribute;
|
||||
if (!is_array($files)) {
|
||||
$this->addError($object, $attribute, $this->uploadRequired);
|
||||
$this->addError($model, $attribute, $this->uploadRequired);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -180,24 +180,24 @@ class FileValidator extends Validator
|
||||
unset($files[$i]);
|
||||
}
|
||||
}
|
||||
$object->$attribute = array_values($files);
|
||||
$model->$attribute = array_values($files);
|
||||
if (empty($files)) {
|
||||
$this->addError($object, $attribute, $this->uploadRequired);
|
||||
$this->addError($model, $attribute, $this->uploadRequired);
|
||||
}
|
||||
if (count($files) > $this->maxFiles) {
|
||||
$this->addError($object, $attribute, $this->tooMany, ['limit' => $this->maxFiles]);
|
||||
$this->addError($model, $attribute, $this->tooMany, ['limit' => $this->maxFiles]);
|
||||
} else {
|
||||
foreach ($files as $file) {
|
||||
$result = $this->validateValue($file);
|
||||
if (!empty($result)) {
|
||||
$this->addError($object, $attribute, $result[0], $result[1]);
|
||||
$this->addError($model, $attribute, $result[0], $result[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = $this->validateValue($object->$attribute);
|
||||
$result = $this->validateValue($model->$attribute);
|
||||
if (!empty($result)) {
|
||||
$this->addError($object, $attribute, $result[0], $result[1]);
|
||||
$this->addError($model, $attribute, $result[0], $result[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -334,22 +334,22 @@ class FileValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function clientValidateAttribute($object, $attribute, $view)
|
||||
public function clientValidateAttribute($model, $attribute, $view)
|
||||
{
|
||||
ValidationAsset::register($view);
|
||||
$options = $this->getClientOptions($object, $attribute);
|
||||
$options = $this->getClientOptions($model, $attribute);
|
||||
return 'yii.validation.file(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the client side validation options.
|
||||
* @param \yii\base\Model $object the model being validated
|
||||
* @param \yii\base\Model $model the model being validated
|
||||
* @param string $attribute the attribute name being validated
|
||||
* @return array the client side validation options
|
||||
*/
|
||||
protected function getClientOptions($object, $attribute)
|
||||
protected function getClientOptions($model, $attribute)
|
||||
{
|
||||
$label = $object->getAttributeLabel($attribute);
|
||||
$label = $model->getAttributeLabel($attribute);
|
||||
|
||||
$options = [];
|
||||
if ($this->message !== null) {
|
||||
|
Reference in New Issue
Block a user