…where ever string eval can be used e.g. CGridView columns value.
The current framework is compatible with PHP 5.2 and so can’t use anonymous functions. 2.0 will be PHP 5.3+ though.
Good to hear.
CComponent::evaluateExpression() does accept anonymous functions. Just try it ![]()
EDIT: An example for CGridView from my current project:
'columns' => array(
//...
array(
'class' => 'CLinkColumn',
'label' => 'jogosultság hozzárendelése',
'urlExpression' => function ($data, $row, $component) { return array('assignRole', 'id' => $data->id); },
),
),
holy moly, thanks for that! How do you know the method signature for the function?
In fact, it isn’t documented, so it may not be safe to rely on. I had to take a look at the code of Yii, to figure it out.
It’s safe to rely on. I promise.