CException "Name:Type:Label"

hey guys, i’m having this error, and can’t find a way to fix it. could you please help me understand what the problem is, and thereby help me fix it?


CException


The attribute must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.


/Applications/MAMP/htdocs/yiiroot/framework/zii/widgets/CDetailView.php(179)


167     {

168         $formatter=$this->getFormatter();

169         echo CHtml::openTag($this->tagName,$this->htmlOptions);

170 

171         $i=0;

172         $n=is_array($this->itemCssClass) ? count($this->itemCssClass) : 0;

173                         

174         foreach($this->attributes as $attribute)

175         {

176             if(is_string($attribute))

177             {

178                 if(!preg_match('/^([\w\.]+)(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />\w*))?(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />.*))?$/',$attribute,$matches))

179                     throw new CException(Yii::t('zii','The attribute must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'));

180                 $attribute=array(

181                     'name'=>$matches[1],

182                     'type'=>isset($matches[3]) ? $matches[3] : 'text',

183                 );

184                 if(isset($matches[5]))

185                     $attribute['label']=$matches[5];

186             }

187             

188             if(isset($attribute['visible']) && !$attribute['visible'])

189                 continue;

190 

191             $tr=array('{label}'=>'', '{class}'=>$n ? $this->itemCssClass[$i%$n] : '');


Stack Trace

#0	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CBaseController.php(174): CDetailView->run()

#1	

–  /Applications/MAMP/htdocs/Pgamers/protected/views/guide/view.php(31): CBaseController->widget("zii.widgets.CDetailView", array("data" => Guide, "attributes" => array("´id´", "´name´", "´description´", "´class_id´", ...)))

26         '´create_time´',

27         '´create_user_id´',

28         '´update_time´',

29         '´update_user_id´',

30     ),

31 )); 

32 ?>

#2	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CBaseController.php(127): require("/Applications/MAMP/htdocs/Pgamers/protected/views/guide/view.p...")

#3	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CBaseController.php(96): CBaseController->renderInternal("/Applications/MAMP/htdocs/Pgamers/protected/views/guide/view.p...", array("model" => Guide), true)

#4	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CController.php(870): CBaseController->renderFile("/Applications/MAMP/htdocs/Pgamers/protected/views/guide/view.p...", array("model" => Guide), true)

#5	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CController.php(783): CController->renderPartial("view", array("model" => Guide), true)

#6	

–  /Applications/MAMP/htdocs/Pgamers/protected/controllers/GuideController.php(55): CController->render("view", array("model" => Guide))

50      */

51     public function actionView($id)

52     {

53         $this->render('view',array(

54             'model'=>$this->loadModel($id),

55         ));

56     }

57 

58     /**

59      * Creates a new model.

60      * If creation is successful, the browser will be redirected to the 'view' page.

#7	

 unknown(0): GuideController->actionView("2")

#8	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/actions/CAction.php(107): ReflectionMethod->invokeArgs(GuideController, array("2"))

#9	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/actions/CInlineAction.php(48): CAction->runWithParamsInternal(GuideController, ReflectionMethod, array("r" => "guide/view", "id" => "2"))

#10	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CController.php(309): CInlineAction->runWithParams(array("r" => "guide/view", "id" => "2"))

#11	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/filters/CFilterChain.php(134): CController->runAction(CInlineAction)

#12	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/filters/CFilter.php(41): CFilterChain->run()

#13	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CController.php(1146): CFilter->filter(CFilterChain)

#14	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)

#15	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain)

#16	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CController.php(292): CFilterChain->run()

#17	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CController.php(266): CController->runActionWithFilters(CInlineAction, array("accessControl"))

#18	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CWebApplication.php(276): CController->run("view")

#19	

+  /Applications/MAMP/htdocs/yiiroot/framework/web/CWebApplication.php(135): CWebApplication->runController("guide/view")

#20	

+  /Applications/MAMP/htdocs/yiiroot/framework/base/CApplication.php(162): CWebApplication->processRequest()

#21	

–  /Applications/MAMP/htdocs/Pgamers/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();




You have a syntax error in CDetailView::attributes.

Could you post your code fragments where your are calling CDetailView?

here:


<?php $this->widget('zii.widgets.CDetailView', array(

	'data'=>$model,

	'attributes'=>array(

		'´id´',

		'´name´',

		'´description´',

		'´class_id´',

		'´owner_id´',

		'´create_time´',

		'´create_user_id´',

		'´update_time´',

		'´update_user_id´',

	),

)); 

?>




<?php $this->widget('zii.widgets.CDetailView', array(

	'data'=>$model,

	'attributes'=>array(

		'id',

		'name',

		'description',

		...

)); 

?>



:)

well, if you are referring to the ´´ around the attributes, thats not a mistake. i sort of made that mistake when i created the database (and this is just a testing application so i didn’t care that much). so i guess the problem lies somewhere else.

I think it’s obvious that the strings like ‘´id´’ are the cause of the exception.

They don’t match the pattern that CDetailView accepts as ‘attribute’.

ok, i still don’t know exactly what caused the exception, but i tried to delete the model, views and controller of the “tbl_guide”. i then renamed all of the columns so they wouldn’t have the ´´around them, whereafter i re-did the model, views and controller. now it all works.

but anyway, thanks for your time