Help needed to display data in table format

How do i display data in table format using CGridView.

I have already changed view.php as follows

$dataProvider=new CActiveDataProvider('Expense');

$this->widget('zii.widgets.grid.CGridView', array(



now what should i have in _view.php to display it in Tabluar format.

Also is there a way to provide default values in $form->textfield

I’m just starting with Yii. Help appreciated


You need to tell the widget which columns you want the table to have:

$this->widget('zii.widgets.grid.CGridView', array(








For the form, you can have it display the value that’s currently set in the model by using the CActiveForm widget for the $form.

	<?php echo $form->labelEx($model,'modelProperty1'); ?>

	<?php echo $form->textField($model,'modelProperty1'); ?>

	<?php echo $form->error($model,'modelProperty1'); ?>

I believe there are some good examples of how to use the CActiveForm widget in the Cookbook section.

Perfect solution for newbi in YII , I had facing same issues but this solution is very helpful for me… :) Thanks to Dana…

Thanks it works :rolleyes: