I am a newbie in YII and building my first application using it. I am using CTabView in my application and it works fine. Here’s a snippet of code i am using:
$user_detail = User::model()->findByAttributes(array(‘id’=>Yii::app()->user->id)); // User data
$viewData = array
$Tabs = array
'tab2'=>array('title'=>'Edit My Preferences','view'=>'/user/managepreferences'),
$this->widget('CTabView', array('tabs'=>$Tabs, 'viewData'=>$viewData, 'activeTab'=>'tab2'));
But my issue is that tab system works fine if everything like writing logic, querying the database is done in the view itself, which is not good, for example for userpreferences i want to call controller action, write my logic there and render the view from there. But, i am unable to do this. If cTabView is for views specific tasks only, then do i need to write all the logic in the view itself?
I want to list user data in managepreferences view and want to update the data from controller istead of the view itself.
You can pass data from the controller to the view, see http://www.yiiframework.com/doc/guide/1.1/en/basics.view.
Yes, i can, but the issue is how to specify a controller for the tab view?
We can only specify view for that tab and not the controller.
Hope you are getting me!
I don’t know if I got it, but the view with the CTabView is called (via the render method) from a controller.
Maybe you want to have multiple controller/actions to render the multiple tabs in a CTabView. Is this correct?
Hello, I also have this problem - I want to call some controller actions, which have my business logic. I tried to do this using url:
It’s working, but my content renders not in the field of tab’s view.
Sorry for my English, if I wrote something wrong.
That’s because you’re creating a link to other page. See CTabView on how to specify the content of the tab.
I wonder if soemeone has found a good logical way to solve this problem ?
Let’s imagine we have three tables making CRUD for each one with gii,
then want to display each CRUD in it’s own tab…on the same page
Here there are 3 controllers involved…
At this step I am stuck as each CRUD has it’s own render() so maybe it could be change
to renderPartial() but how to redirect these partial rendering inside the correct tab ?
According to documentation CTabView will be rendered using the current controller
but if so maybe should join the three CRUD in only one big controller, which maybe
quite a dirty work…