Код: Выделить всё
public function rules() {
return [
// ...
['parent_id', 'exist', 'targetClass' => self::class, 'targetAttribute' => ['parent_id' => 'id'],
'message' => 'Нет статьи с таким id', 'when' => function($value) {return !$value;}],
['next_id', 'exist', 'targetClass' => self::class, 'targetAttribute' => ['next_id' => 'id'],
'message' => 'Нет статьи с таким id', 'when' => function($value) {return !$value;}],
['prev_id', 'exist', 'targetClass' => self::class, 'targetAttribute' => ['prev_id' => 'id'],
'message' => 'Нет статьи с таким id', 'when' => function($value) {return !$value;}],
// ...
];
}
Код: Выделить всё
public function rules() {
return [
// ...
[['parent_id', 'next_id', 'prev_id'], 'exist',
'targetClass' => self::class, 'targetAttribute' => ['???' => 'id'],
'message' => 'Нет статьи с таким id', 'when' => function($value) {return !$value;}],
// ...
];
}