$model = new Product;
$model->name = 'Товар 1';
Толстые контроллеры? Где они толстые-то? Вот пример круда
<?php
/**
* Manage News
* @author Troy <[email protected]>
*/
class NewsAdminController extends BaseAdminController
{
public function actionView($id)
{
$this->render('view', array(
'model' => $this->loadModel('News', $id),
));
}
public function actionCreate()
{
$model = new News;
$form = new Form('forms.News', $model);
if ($form->submited() && $model->save())
$this->redirect(array('view', 'id' => $model->id));
$this->render('create', array(
'form' => $form,
));
}
public function actionDelete($id)
{
$this->loadModel($id)->delete();
if (!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
public function actionUpdate($id)
{
$model = $this->loadModel('News', $id);
$form = new Form('forms.News', $model);
if ($form->submited() && $model->save())
$this->redirect(array('view', 'id' => $model->id));
$this->render('create', array(
'form' => $form,
));
}
public function actionIndex()
{
$model = new News('search');
$model->unsetAttributes();
if (isset($_GET['News']))
$model->attributes = $_GET['News'];
$this->render('admin', array(
'model' => $model,
));
}
}