А как можно сделать валидатор на запрет изменения данных? Актуально для апи
Asked
Active
Viewed 170 times
2 Answers
0
/**
* @inheritdoc
*/
public function rules()
{
return [
['name', 'notModifyValidator']
];
}
/**
* Валидатор проверки изменения аттрибута.
*
* @param $attribute
* @return bool
*/
public function notModifyValidator($attribute)
{
if ($this->isAttributeChanged($attribute)) {
$this->addError($attribute, 'ТЕКСТ ОШИБКИ');
return false;
}
}
des1roer
- 2,676