I have the following class so that I can customize my button column for admin actions:
class ButtonColumn extends CButtonColumn {
public $template = '{update} {delete}';
public $buttons= array(
'update'=>array(
'label'=>'Update',
'imageUrl'=>Yii::app()->theme->baseUrl . '/images/icons/edit.png',
),
'delete'=>array(
'label'=>'Delete',
'imageUrl'=>Yii::app()->theme->baseUrl . '/images/icons/delete.png',
),
);
}
With that class being used, I receive the error “Parse error: syntax error, unexpected ‘(’, expecting ‘)’.” If I take the “imageUrl” out of this class and place it within the CGridView as “updateButtonImageUrl” it works as expected. For obvious reasons, I don’t want to include that in all of my admin actions, I just want them all to have the update and delete buttons with my new icons.
Why can I not seem to use “Yii::app()->theme->baseUrl” within a class? I know this is my newbie showing through because this must be a concept that I have not yet learned. Can someone please point me in the right direction? Google and the Yii forums haven’t shown me the answer I’m looking for just yet. Thank you!
If I toss that onto the view.php page, I get ‘string(24) “/themes/admin-chromatron”’ so it seems to work there as well. Like I mentioned earlier, I can set the correct image within CGridView using ‘updateButtonImageUrl’ but when I try to make the exact same line of code work within my class, it doesn’t work.
Do you not have access to Yii::app() within a class? Or do you have access to it but need to reference it differently? The way php is complaining about an unexpected opening parenthesis makes me wonder what I need to be using other than app().