Problema con CGridView y CButtonColumn

Hola, el problema es que me esta dando un error que no se porque me da si en otras vista me funciona el mismo codigo perfectamente. El problema es que si yo en el CGridView en el template tengo {view}{update}{delete}’, me da el error que esta abajo, pero si le quito el {delete} y dejo a

{view}{update} no me da error, aclaro que en template tengo el metodo


this->validaTemplate('datMuestra') 

lo unico que hace es verificar si el usuario tiene permiso a update, delete o view y entonces esa funcion devuele {view}{update}{delete} en dependencia de a cuales tiene permiso.




PHP Error


Trying to get property of non-object


/home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/base/CComponent.php(619) : eval()'d code(1)

Stack Trace

#0 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/base/CComponent.php(619): eval()


614     public function evaluateExpression($_expression_,$_data_=array())

615     {

616         if(is_string($_expression_))

617         {

618             extract($_data_);

619             return eval('return '.$_expression_.';');

620         }

621         else

622         {

623             $_data_[]=$this;

624             return call_user_func_array($_expression_, $_data_);


#1 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/grid/CButtonColumn.php(314): CComponent->evaluateExpression("Yii::app()->controller->createUrl("delete",array("id"=>$data->pr...", array("data" => array("idmuestra" => "10", "codigo" => "4444", "fecha_entrada" => "2011-05-28", "numero_muestra" => 6, ...), "row" => 0))


309     protected function renderButton($id,$button,$row,$data)

310     {

311         if (isset($button['visible']) && !$this->evaluateExpression($button['visible'],array('row'=>$row,'data'=>$data)))

312               return;

313         $label=isset($button['label']) ? $button['label'] : $id;

314         $url=isset($button['url']) ? $this->evaluateExpression($button['url'],array('data'=>$data,'row'=>$row)) : '#';

315         $options=isset($button['options']) ? $button['options'] : array();

316         if(!isset($options['title']))

317             $options['title']=$label;

318         if(isset($button['imageUrl']) && is_string($button['imageUrl']))

319             echo CHtml::link(CHtml::image($button['imageUrl'],$label),$url,$options);


#2 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/grid/CButtonColumn.php(293): CButtonColumn->renderButton("delete", array("label" => "Eliminar", "url" => "Yii::app()->controller->createUrl("delete",array("id"=>$data->pr...", "imageUrl" => "/assets/bc1b6232/gridview/delete.png", "options" => array("class" => "delete"), ...), 0, array("idmuestra" => "10", "codigo" => "4444", "fecha_entrada" => "2011-05-28", "numero_muestra" => 6, ...))


288     {

289         $tr=array();

290         ob_start();

291         foreach($this->buttons as $id=>$button)

292         {

293             $this->renderButton($id,$button,$row,$data);

294             $tr['{'.$id.'}']=ob_get_contents();

295             ob_clean();

296         }

297         ob_end_clean();

298         echo strtr($this->template,$tr);


#3 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/grid/CGridColumn.php(135): CButtonColumn->renderDataCellContent(0, array("idmuestra" => "10", "codigo" => "4444", "fecha_entrada" => "2011-05-28", "numero_muestra" => 6, ...))


130                 $options['class'].=' '.$class;

131             else

132                 $options['class']=$class;

133         }

134         echo CHtml::openTag('td',$options);

135         $this->renderDataCellContent($row,$data);

136         echo '</td>';

137     }

138 

139     /**

140      * Renders the footer cell.


#4 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/grid/CGridView.php(512): CGridColumn->renderDataCell(0)


507         else if(is_array($this->rowCssClass) && ($n=count($this->rowCssClass))>0)

508             echo '<tr class="'.$this->rowCssClass[$row%$n].'">';

509         else

510             echo '<tr>';

511         foreach($this->columns as $column)

512             $column->renderDataCell($row);

513         echo "</tr>\n";

514     }

515 

516     /**

517      * @return boolean whether the table should render a footer.


#5 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/grid/CGridView.php(485): CGridView->renderTableRow(0)


480         echo "<tbody>\n";

481 

482         if($n>0)

483         {

484             for($row=0;$row<$n;++$row)

485                 $this->renderTableRow($row);

486         }

487         else

488         {

489             echo '<tr><td colspan="'.count($this->columns).'">';

490             $this->renderEmptyText();


#6 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/grid/CGridView.php(395): CGridView->renderTableBody()


390         if($this->dataProvider->getItemCount()>0 || $this->showTableOnEmpty)

391         {

392             echo "<table class=\"{$this->itemsCssClass}\">\n";

393             $this->renderTableHeader();

394             ob_start();

395             $this->renderTableBody();

396             $body=ob_get_clean();

397             $this->renderTableFooter();

398             echo $body; // TFOOT must appear before TBODY according to the standard.

399             echo "</table>";

400         }


#7 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/CBaseListView.php(158): CGridView->renderItems()


153     protected function renderSection($matches)

154     {

155         $method='render'.$matches[1];

156         if(method_exists($this,$method))

157         {

158             $this->$method();

159             $html=ob_get_contents();

160             ob_clean();

161             return $html;

162         }

163         else


#8 	

 unknown(0): CBaseListView->renderSection(array("{items}", "items"))

#9 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/CBaseListView.php(141): preg_replace_callback("/{(\w+)}/", array(CGridView, "renderSection"), "{summary} {items} {pager}")


136      * The rendering results will replace the corresponding placeholders in {@link template}.

137      */

138     public function renderContent()

139     {

140         ob_start();

141         echo preg_replace_callback("/{(\w+)}/",array($this,'renderSection'),$this->template);

142         ob_end_flush();

143     }

144 

145     /**

146      * Renders a section.


#10 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/zii/widgets/CBaseListView.php(126): CBaseListView->renderContent()


121     {

122         $this->registerClientScript();

123 

124         echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";

125 

126         $this->renderContent();

127         $this->renderKeys();

128 

129         echo CHtml::closeTag($this->tagName);

130     }

131 


#11 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CBaseController.php(166): CBaseListView->run()


161             return ob_get_clean();

162         }

163         else

164         {

165             $widget=$this->createWidget($className,$properties);

166             $widget->run();

167             return $widget;

168         }

169     }

170 

171     /**


#12 	

+

–

 /home/pavel/Banco_de_ADN/protected/views/datMuestra/notificaciones.php(62): CBaseController->widget("zii.widgets.grid.CGridView", array("dataProvider" => CArrayDataProvider, "summaryText" => "Mostrando {start}-{end} de {count}", "columns" => array(array("name" => "codigo", "type" => "raw", "htmlOptions" => array("style" => "width:150px;overflow:hidden"), "headerHtmlOptions" => array("style" => "width:150px;overflow:hidden")), array("name" => "fechavencimiento", "value" => "$data["fecha_vencimiento"]", "type" => "raw", "htmlOptions" => array("style" => "width:150px;overflow:hidden"), ...), array("name" => "tiemporestante", "value" => "$data["tiempo_restante"]", "type" => "raw", "htmlOptions" => array("style" => "width:150px;overflow:hidden"), ...), array("class" => "CButtonColumnRF", "template" => "{view}{update}{delete}", "viewButtonLabel" => "Detalle", "updateButtonLabel" => "Modificar", ...))))


57                                             "url"=>"index",

58                             ))',

59                             

60                         ),

61                     ),

62         )); 

63 ?>

64 

65 


#13 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CBaseController.php(119): require("/home/pavel/Banco_de_ADN/protected/views/datMuestra/notificacion...")


114             $data=$_data_;

115         if($_return_)

116         {

117             ob_start();

118             ob_implicit_flush(false);

119             require($_viewFile_);

120             return ob_get_clean();

121         }

122         else

123             require($_viewFile_);

124     }


#14 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CBaseController.php(88): CBaseController->renderInternal("/home/pavel/Banco_de_ADN/protected/views/datMuestra/notificacion...", array("arrayDataProvider" => CArrayDataProvider), true)


83     {

84         $widgetCount=count($this->_widgetStack);

85         if(($renderer=Yii::app()->getViewRenderer())!==null && $renderer->fileExtension==='.'.CFileHelper::getExtension($viewFile))

86             $content=$renderer->renderFile($this,$viewFile,$data,$return);

87         else

88             $content=$this->renderInternal($viewFile,$data,$return);

89         if(count($this->_widgetStack)===$widgetCount)

90             return $content;

91         else

92         {

93             $widget=end($this->_widgetStack);


#15 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CController.php(866): CBaseController->renderFile("/home/pavel/Banco_de_ADN/protected/views/datMuestra/notificacion...", array("arrayDataProvider" => CArrayDataProvider), true)


861      */

862     public function renderPartial($view,$data=null,$return=false,$processOutput=false)

863     {

864         if(($viewFile=$this->getViewFile($view))!==false)

865         {

866             $output=$this->renderFile($viewFile,$data,true);

867             if($processOutput)

868                 $output=$this->processOutput($output);

869             if($return)

870                 return $output;

871             else


#16 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CController.php(779): CController->renderPartial("notificaciones", array("arrayDataProvider" => CArrayDataProvider), true)


774      */

775     public function render($view,$data=null,$return=false)

776     {

777         if($this->beforeRender($view))

778         {

779             $output=$this->renderPartial($view,$data,true);

780             if(($layoutFile=$this->getLayoutFile($this->layout))!==false)

781                 $output=$this->renderFile($layoutFile,array('content'=>$output),true);

782 

783             $this->afterRender($view,$output);

784 


#17 	

+

–

 /home/pavel/Banco_de_ADN/protected/controllers/DatMuestraController.php(228): CController->render("notificaciones", array("arrayDataProvider" => CArrayDataProvider))


223         //$model=new DatMuestraModel('search');

224         //$model->unsetAttributes();  // clear any default values

225 

226         /*if(isset($_GET['DatMuestraModel']))

227         $model->attributes=$_GET['DatMuestraModel'];*/

228         $this->render('notificaciones',array('arrayDataProvider'=>$arrayDataProvider));

229     }

230 

231     /**

232      * Returns the data model based on the primary key given in the GET variable.

233      * If the data model is not found, an HTTP exception will be raised.


#18 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/actions/CInlineAction.php(50): DatMuestraController->actionNotificaciones()


45         $controller=$this->getController();

46         $method=new ReflectionMethod($controller, $methodName);

47         if($method->getNumberOfParameters()>0)

48             return $this->runWithParamsInternal($controller, $method, $params);

49         else

50             return $controller->$methodName();

51     }

52 

53 }


#19 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CController.php(300): CInlineAction->runWithParams(array("r" => "datMuestra/notificaciones"))


295     {

296         $priorAction=$this->_action;

297         $this->_action=$action;

298         if($this->beforeAction($action))

299         {

300             if($action->runWithParams($this->getActionParams())===false)

301                 $this->invalidActionParams($action);

302             else

303                 $this->afterAction($action);

304         }

305         $this->_action=$priorAction;


#20 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/filters/CFilterChain.php(134): CController->runAction(CInlineAction)


129             $filter=$this->itemAt($this->filterIndex++);

130             Yii::trace('Running filter '.($filter instanceof CInlineFilter ? get_class($this->controller).'.filter'.$filter->name.'()':get_class($filter).'.filter()'),'system.web.filters.CFilterChain');

131             $filter->filter($this);

132         }

133         else

134             $this->controller->runAction($this->action);

135     }

136 }


#21 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/filters/CFilter.php(41): CFilterChain->run()


36      */

37     public function filter($filterChain)

38     {

39         if($this->preFilter($filterChain))

40         {

41             $filterChain->run();

42             $this->postFilter($filterChain);

43         }

44     }

45 

46     /**


#22 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CController.php(1144): CFilter->filter(CFilterChain)


1139      */

1140     public function filterAccessControl($filterChain)

1141     {

1142         $filter=new CAccessControlFilter;

1143         $filter->setRules($this->accessRules());

1144         $filter->filter($filterChain);

1145     }

1146 

1147     /**

1148      * Generates pagination information.

1149      * This method can be used to generate pagination information given item count


#23 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)


54      * @param CFilterChain $filterChain the filter chain that the filter is on.

55      */

56     public function filter($filterChain)

57     {

58         $method='filter'.$this->name;

59         $filterChain->controller->$method($filterChain);

60     }

61 }


#24 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain)


126     {

127         if($this->offsetExists($this->filterIndex))

128         {

129             $filter=$this->itemAt($this->filterIndex++);

130             Yii::trace('Running filter '.($filter instanceof CInlineFilter ? get_class($this->controller).'.filter'.$filter->name.'()':get_class($filter).'.filter()'),'system.web.filters.CFilterChain');

131             $filter->filter($this);

132         }

133         else

134             $this->controller->runAction($this->action);

135     }

136 }


#25 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CController.php(283): CFilterChain->run()


278             $this->runAction($action);

279         else

280         {

281             $priorAction=$this->_action;

282             $this->_action=$action;

283             CFilterChain::create($this,$action,$filters)->run();

284             $this->_action=$priorAction;

285         }

286     }

287 

288     /**


#26 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CController.php(257): CController->runActionWithFilters(CInlineAction, array("accessControl"))


252         {

253             if(($parent=$this->getModule())===null)

254                 $parent=Yii::app();

255             if($parent->beforeControllerAction($this,$action))

256             {

257                 $this->runActionWithFilters($action,$this->filters());

258                 $parent->afterControllerAction($this,$action);

259             }

260         }

261         else

262             $this->missingAction($actionID);


#27 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CWebApplication.php(277): CController->run("notificaciones")


272         {

273             list($controller,$actionID)=$ca;

274             $oldController=$this->_controller;

275             $this->_controller=$controller;

276             $controller->init();

277             $controller->run($actionID);

278             $this->_controller=$oldController;

279         }

280         else

281             throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',

282                 array('{route}'=>$route===''?$this->defaultController:$route)));


#28 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/web/CWebApplication.php(136): CWebApplication->runController("datMuestra/notificaciones")


131             foreach(array_splice($this->catchAllRequest,1) as $name=>$value)

132                 $_GET[$name]=$value;

133         }

134         else

135             $route=$this->getUrlManager()->parseUrl($this->getRequest());

136         $this->runController($route);

137     }

138 

139     /**

140      * Registers the core application components.

141      * This method overrides the parent implementation by registering additional core components.


#29 	

+

–

 /home/pavel/Banco_de_ADN/yii/yii-1.1.8/framework/base/CApplication.php(158): CWebApplication->processRequest()


153      */

154     public function run()

155     {

156         if($this->hasEventHandler('onBeginRequest'))

157             $this->onBeginRequest(new CEvent($this));

158         $this->processRequest();

159         if($this->hasEventHandler('onEndRequest'))

160             $this->onEndRequest(new CEvent($this));

161     }

162 

163     /**


#30 	

+

–

 /home/pavel/Banco_de_ADN/index.php(13): CApplication->run()


08 defined('YII_DEBUG') or define('YII_DEBUG',true);

09 // specify how many levels of call stack should be shown in each log message

10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

11 

12 require_once($yii);

13 Yii::createWebApplication($config)->run();






/*Este es el Grid en la vista*/


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

		'dataProvider'=>$arrayDataProvider,

		//'htmlOptions'=>array('style'=>'width: 490px'),

	    'summaryText'=>'Mostrando {start}-{end} de {count}',

		'columns'=>array(

				

						array(

							'name'=>'codigo',

							'type'=>'raw',

							'htmlOptions'=>array('style'=>'width:150px;overflow:hidden'),

							'headerHtmlOptions'=>array('style'=>'width:150px;overflow:hidden'),

						),

						array(

							'name'=>'fechavencimiento',

							'value'=>'$data["fecha_vencimiento"]',

							'type'=>'raw',

							'htmlOptions'=>array('style'=>'width:150px;overflow:hidden'),

							'headerHtmlOptions'=>array('style'=>'width:150px;overflow:hidden'),

						),

						array(

							'name'=>'tiemporestante',

							'value'=>'$data["tiempo_restante"]',

							'type'=>'raw',

							'htmlOptions'=>array('style'=>'width:150px;overflow:hidden'),

							'headerHtmlOptions'=>array('style'=>'width:150px;overflow:hidden'),

						),

						

						array(//botones que aparecen e el grid

							'class'=>'CButtonColumnRF',

							          'template'=>$this->validaTemplate('datMuestra'),

							'viewButtonLabel'=>'Detalle',

							'updateButtonLabel'=>'Modificar',

							'deleteButtonLabel'=> 'Eliminar',

							'updateButtonUrl'=>'Yii::app()->controller->createUrl("datMuestra/Update",array(

											"id"=>$data["idmuestra"],

											"url"=>"index",

							))',

							'viewButtonUrl'=>'Yii::app()->controller->createUrl("datMuestra/View",array(

											"id"=>$data["idmuestra"],

											"url"=>"index",

							))',

							

						),

					),

		)); 




/*Esta es la accion en la controladora*/


public function actionNotificaciones()

	{

		$muestras = DatMuestraModel::model()->findAll();   

		$arrayMuestrasParaNotificar = array();

        $fechaActual = strtotime(date('Y-m-d'));

       

		foreach ($muestras as $muestra)

		{

			$fechaVencimiento =  strtotime("$muestra->fecha_entrada + $muestra->conservacion year");

			$fecha=date('Y-m-d',$fechaVencimiento);

			$fechaInicioNotificacion = strtotime("$fecha - 60 days");

			$tiempo_restante = $this->restaFechas(date("d-m-Y"),date("d-m-y",$fechaVencimiento));

			$term = "dias";

            if ($tiempo_restante==1)

                  $term = "dia";

			if( $fechaInicioNotificacion <= $fechaActual && $fechaActual <= $fechaVencimiento)

			{

				$arrayMuestra['idmuestra'] = $muestra['idmuestra'];

				$arrayMuestra['codigo'] = $muestra['codigo'];

				$arrayMuestra['fecha_entrada'] = $muestra['fecha_entrada'];

				$arrayMuestra['numero_muestra'] = $muestra['numero_muestra'];

				$arrayMuestra['conservacion'] = $muestra['conservacion'];

				$arrayMuestra['descripcion'] = $muestra['descripcion'];

				$arrayMuestra['observaciones'] = $muestra['observaciones'];

				$arrayMuestra['diagnostico_molecular'] = $muestra['diagnostico_molecular'];

				$arrayMuestra['idpaciente'] = $muestra['idpaciente'];

				$arrayMuestra['idsolucion'] = $muestra['idsolucion'];

				$arrayMuestra['idstatus'] = $muestra['idstatus'];

				$arrayMuestra['idproyecto'] = $muestra['idproyecto'];

				$arrayMuestra['intervalo_postmorten'] = $muestra['intervalo_postmorten'];

				$arrayMuestra['idmetodobtencion'] = $muestra['idmetodobtencion'];

				$arrayMuestra['iddiagnostico'] = $muestra['iddiagnostico'];

				$arrayMuestra['volumen']  = $muestra['volumen'];

				$arrayMuestra['cantidad_tubo'] = $muestra['cantidad_tubo'];

				$arrayMuestra['idestructura'] = $muestra['idestructura'];

				$arrayMuestra['autorizo'] = $muestra['autorizo'];

				$arrayMuestra['eliminado'] = $muestra['eliminado'];

                $arrayMuestra['fecha_vencimiento'] = date('d-m-Y',strtotime($fecha));

                $arrayMuestra['tiempo_restante'] = $tiempo_restante." ".$term;

                $arrayMuestrasParaNotificar[] = $arrayMuestra;

			}

		}

		$arrayDataProvider=new CArrayDataProvider($arrayMuestrasParaNotificar, array(

		'id'=>'muestras',

		'keyField'=>'idmuestra',

		'pagination'=>array(

		'pageSize'=>10,

		),

		));

	


		//$model=new DatMuestraModel('search');

		//$model->unsetAttributes();  // clear any default values


		/*if(isset($_GET['DatMuestraModel']))

		$model->attributes=$_GET['DatMuestraModel'];*/

		$this->render('notificaciones',array('arrayDataProvider'=>$arrayDataProvider));

	}

array(

					    'class'=&gt;'CButtonColumnRF',


						'template'=&gt;&#036;this-&gt;validaTemplate(&quot;datMuestra&quot;),


						'buttons'=&gt;array(


						    'view'=&gt;array(


						         'label'=&gt;'Detalle',


						         'url'=&gt;'Yii::app()-&gt;controller-&gt;createUrl(&quot;datMuestra/View&quot;,array(


										&quot;id&quot;=&gt;&#036;data[&quot;idmuestra&quot;],


										&quot;url&quot;=&gt;&quot;notificaciones&quot;,


										


						             ))',


						         'visible'=&gt;'&#036;data[&quot;visible&quot;]',


						    ),


						    'update'=&gt;array(


						        'label'=&gt;'Modificar',


						        'url'=&gt;'Yii::app()-&gt;controller-&gt;createUrl(&quot;datMuestra/Update&quot;,array(


										&quot;id&quot;=&gt;&#036;data[&quot;idmuestra&quot;],


										&quot;url&quot;=&gt;&quot;notificaciones&quot;,


										


						             ))',


						        'visible'=&gt;'&#036;data[&quot;visible&quot;]',


						    ),


						    'delete'=&gt;array(


						        'label'=&gt;'Eliminar', 


						        'url'=&gt;'Yii::app()-&gt;controller-&gt;createUrl(&quot;datMuestra/Delete&quot;,array(


										&quot;id&quot;=&gt;&#036;data[&quot;idmuestra&quot;],


										&quot;url&quot;=&gt;&quot;notificaciones&quot;,


										


						          ))',


						     ),


						),


					),

En la propiedad button no estaba url a delete entonces parece que me daba bateo con la propiedad

public deleteButtonUrl=‘Yii::app()->controller->createUrl(“delete”,array(“id”=>$data->primaryKey))’;

que esta en la clase CButtonColumn y como uso un CArrayDataProvider parece que daba bateo.