/** * This method accepts category and creates the model. * Returns model if successfully created. * Returns the error validated model if validation fails. * * * @param string $category * @return model || model with errors */ public static function addJukeboxCategory($category) { $jukeboxCategory = new JukeboxCategory(); $jukeboxCategory->category = $category; $jukeboxCategory->save(); return $jukeboxCategory; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new JukeboxCategory(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['JukeboxCategory'])) { $model->attributes = $_POST['JukeboxCategory']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }