CButtonColumn - specifying URL problem?

For CButtonColumn, I’m trying to specify a custom button.

I have this code, and it’s rendering properly:




array(

     'class'=>'CButtonColumn',

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

     'buttons'=>array(

          'goal'=>array(

               'label'=>'Goals >>',

               'url'=>Yii::app()->controller->createUrl('goal/admin'),

           ),

     ),

),



However, I keep getting this error when I have the ‘url’ property specified:

I’ve dug all around the documentation and classes, and can’t quite figure out where this is coming from. Does anybody have a suggestion? I think I’m specifying the URL properly; unless I’m misunderstanding it - I’m trying to take the user to the ‘goal/admin’ page when they click the button.

Try


Yii::app()->controller->createUrl(array('goal/admin'))

That’s one of the first things I tried… oddly enough, when I do that, the renderPartial() which is displaying the form containing the CGridView just - doesn’t render. No errors, nothing. Perhaps the ‘url’ property need another button property specified before it can render correctly… I’m at a total loss here?

It seems you are trying to use real code that is being evaluated. Instead you should use a string:




array(

     'class'=>'CButtonColumn',

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

     'buttons'=>array(

          'goal'=>array(

               'label'=>'Goals >>',

               'url'=> "Yii::app()->controller->createUrl('goal/admin')",

           ),

     ),

),



Ooooohh… :rolleyes: that solved the problem - thanks; I never would have thought to look at that.

Alright; now here’s another problem.

I’m trying to have this button submit with ajax to a actionMain() function in my ‘Goal’ controller class, and then have that action do a renderPartial() in the form.

Unfortunately, I can’t seem to figure out how to specify ajax options for CButtonColumn - I didn’t have a problem doing it with the CJuiTabs widget, or links, but I can’t see to get it for the CButtonColumn. I tried using CHtml::ajax() in the ‘click’ array options, like so:




'class'=>'CButtonColumn',

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

      'buttons'=>array(

           'goal'=>array(

                'label'=>'Goals >>',       'url'=>'Yii::app()->controller->createUrl("goal/main",array("issueOID"=>$data->issue_oid,"projectOID"=>'.$projectOID.'))',

           'click'=>'CHtml::ajax(array("update"=>"ajaxPanel")',

      ),

),

… but I really have no idea. “ajaxPanel” is on the page, and it works with anything but CButtonColumn. Any suggestions? I tried looking through the older Yii code, when the controllers used to accept ajax delete links before CButtonColumns came along, but couldn’t find the answer.

Thanks.

How to make page open in another browser’s tab using url in CGridView? In other words when clicking view button I want the page to open in another tab.

Set the options for the button:




'options'=>array('target'=>'_blank')



Thank you. It works. :)