Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CButtonColumn.buttons's 'imageUrl' property should also allow a PHP expression #3968

Closed
teo1978 opened this issue Oct 11, 2015 · 0 comments
Closed

Comments

@teo1978
Copy link

teo1978 commented Oct 11, 2015

http://www.yiiframework.com/doc/api/1.1/CButtonColumn#buttons-detail

public array $buttons;
the configuration for buttons. Each array element specifies a single button which has the following format:

'buttonID' => array(
    'label'=>'...',     // text label of the button
    'url'=>'...',       // a PHP expression for generating the URL of the button
    'imageUrl'=>'...',  // image URL of the button. If not set or false, a text link is used
    'options'=>array(...), // HTML options for the button tag
    'click'=>'...',     // a JS function to be invoked when the button is clicked
    'visible'=>'...',   // a PHP expression for determining whether the button is visible
)

Like url and visible, imgUrl should also accept a PHP expression for the url (I'm not sure how to allow this while maintaining BC, i.e. be able to accept both an url and a PHP expression for computing it, but there's certainly a way).

My use case for this is the following:
I want to create a button column that only has a custom button which uses the default image normally used for the update button. In order to do so, I need access to the grid object.
Of course there are a number of ugly workarounds like using assetManager to pick the image from the location where the assets of CGridView are (but this wouldn't work or should be changed if we were using some custom subclass of CGridView).

But it's easy to imagine other use cases, such as a custom button whose icon may vary depending on some property of $data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants