How To wigetized a single view using several models in Yii?

328 Views Asked by At


Am working on Yii application, which has only one view -'Dashboard', i need to do all application activity on this single interface. like as show all user details, account, history, status with curd facility.

--In Controller--
class DashboardController 
{
    public function actionDashboard()
    {
        $model = new MyDashboard;
        if(isset($_POST['MyDashboard']))
        {
             $this->model->save();
        }
        $this->render('dashboard',array('model'=>$model));
    }
}


-- In Dashboard View --
 // userd-details
 $this->widget('application.components.widgets.addGruopWidget.userdetails');

 //account
 $this->widget('application.components.widgets.addGruopWidget.useraccount');

 //user status
 $this->widget('application.components.widgets.addGruopWidget.userstatus');

 //user history
 $this->widget('application.components.widgets.addGruopWidget.userhistory');

So how to define all curd activity for user on this single 'Dashboard' interface using DashboardController. plz suggest solution if possible. Thanks !!!

1

There are 1 best solutions below

0
On
public function actionDashboard($action=null){

  if(!is_null($action) && strlen($action)>0){
    $method = "run".ucfirst($action);
    if(method_exists($this,$method)){
      $this->$method(); // if $action is 'actionName' then $this->runActionName();
      Yii::app()->end();
    }
  }
}


...
}


protected function runActionName(){
   /*  dp something  */
}