CButtonColumn Buttons

I want to hide the "view" button, how can I do this?


        array(

            'class'=>'CButtonColumn',

            'template'=>'{update} {delete}',

        ),



If you want to hide it permanently, remove it from template property, as Mike showed you.

If you wish to hide it only in certain situations or basing upon some circumstances, use buttons property, add interesting (view) button id there and use visible parameter of its array to pass there a PHP expression which will be then evaluated each time to check whether button should be displayed or not.

Look into my cookbook article for more information on customizing CButtonColumn class.

I’m pulling my hair out here, I can’t hide any of it… I’ve tried:

  • using visible false

  • removing one from the template

  • removing the entire button array

I’m uploading to the correct server too! I had to include a new column just to see if I was looking at the right page!

Is there a deep default somewhere in the bones of YII for forms?


array

		(

			'class'=>'CButtonColumn',

			'template'=>'{view}{update}{delete}',

			'buttons'=>array

			(

				'view' => array

				(

					'url'=>'CController::createUrl("/leads/view", array("id_lead"=>$data->primaryKey))',

				),

				'update' => array

				(

					'url'=>'CController::createUrl("/leads/update", array("id_lead"=>$data->primaryKey))',

				),

				'delete' => array

				(

					'url'=>'CController::createUrl("/leads/delete", array("id_lead"=>$data->primaryKey))',

				),

			),

		),

If you remove {view} from the template, the button should disappear. Can you not test the site on your local machine?

I realise what’s happening now, the controller is rendering a different page, OMG! :-X so thats why my changes are not showing.

I’ve gone with ‘template’=>’{view}’ for now…

I’m off to the 12th floor to find an open window!