function beforeSave($insert) { parent::beforeSave($insert); if ($this->isNewRecord) { $this->password = SecurityHelper::generatePasswordHash($this->password); } else { //更新密码 $this->password = SecurityHelper::generatePasswordHash($this->new_password); } return true; }
function beforeSave($insert) { parent::beforeSave($insert); if ($this->attach) { if (is_array($this->attach)) { $this->attach = serialize($this->attach); } } else { $this->attach = ""; } return true; }
/** * 保存数据前,对pid判断,是否是正确的移动 * 如移到到自己及自己所属的子分类将提示移动失败 * pid 值将不会被保存 */ function beforeSave($insert) { parent::beforeSave($insert); if ($this->id) { $data = static::find()->all(); if ($data) { $out = \app\core\Arr::model_tree($data, $value = 'name', $id = 'id', $pid = 'pid', $this->id); $out[$this->id] = $this->id; } else { $out[$this->id] = $this->id; } if ($out[$this->pid]) { $this->pid = $this->old_pid; flash('error', __('try change tree error')); } } return true; }
function beforeDelete() { parent::beforeDelete(); Widget::find(array('field_id' => $this->id))->delete(); }
function afterFind() { parent::afterFind(); $this->old = $this->from_password; $this->from_password = ""; }