Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Error With Data Provider To Cgridview

$
0
0
Hello guys hope you are well,

I'm a beginner in YII and is still learning it,
Ive tried to include a CGridView onto my view (which is the create form).

In my _form (view)
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'principalcomments-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
              array(
                'name'=>'staff_name',
                'value'=>'$data->timetable->academicstaff->nameWithInitials',
                ),
                'datecommented',
		'comment',
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>


everything works fine but the filter is not working.

I modified my controllers' actionCreate like:-

public function actionCreate()
	{
            
		$model=new Principalcomments;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

                               
		if(isset($_POST['Principalcomments']))
		{
			$model->attributes=$_POST['Principalcomments'];
			if($model->save())
                            $this->refresh();
			//	$this->redirect(array('view','id'=>$model->commentId));
		}
                
                $model=new Principalcomments('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Principalcomments']))
			$model->attributes=$_GET['Principalcomments'];
                
                
                
              $this->render('create',array(
			'model'=>$model,
		));
             
	}


Still this doesnt work, can someone please help me put it right.....

Any help is greatly appreciated, thanks a lot...

Cheerz!

:)

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>