function create() { $model = new Cate(); if ($this->isPost()) { $model->setAttributes($this->post('Cate')); if ($model->save()) { $this->redirect(url('/admin/cate')); } } $this->render('create', array('model' => $model)); }
public function save() { if (!$this->validate()) { return false; } $model = new Cate(); $model->setAttributes($this->getAttributes()); !$model->pid && ($model->pid = 0); if (!$model->save()) { $this->addErrors($model->getErrors()); return false; } return true; }