我的 Yii2 模型的 AfterSave 函数中有这个奇怪的错误
当我这样做时
public function afterSave($insert, $changedAttributes) {
parent::afterSave($insert, $changedAttributes);
if(!$insert):
print_r($changedAttributes);exit;
$this->prepareMail(self::MAIL_APPROVE);
;
}
我明白了
Array (
[reason_for_travel] => 1 [project_id] => [billable] => 1
[advance_required] => 0 [status] => 2 ) // See it contains 'status'
但是当我这样做时
public function afterSave($insert, $changedAttributes) {
parent::afterSave($insert, $changedAttributes);
if(!$insert):
$status = $changedAttributes['status']; // this line shows error
if($status == Self::STATUS_CONFIRMED):
$this->prepareMail(self::MAIL_APPROVE);
;
;
}
$status = $changedAttributes['status']; 此行显示错误
错误是“未定义的索引:状态”
我没看到什么?