Skip to content
Browse files

Fixes #1391: CDetailView: callables (including anonymous functions fo…

…r PHP 5.3+) could be used as value generators of the attributes.
  • Loading branch information...
1 parent 70db8bd commit c993457dff6b08194d8122d25cb440dfc7688d1f @resurtm committed Sep 14, 2012
Showing with 5 additions and 2 deletions.
  1. +1 −0 CHANGELOG
  2. +4 −2 framework/zii/widgets/CDetailView.php
@@ -35,6 +35,7 @@ Version 1.1.13 work in progress
- Enh #1299: Added CSRF token validation for PUT and DELETE (miraage, samdark)
- Enh #1369: Added CCheckBoxColumn::disabled that accepts PHP expression or anonymous function determining if checkbox for the row should be disabled (sucotronic)
- Enh #1386: Second parameter of the CHtml::value() is now able to accept anonymous function which calculates value to be used (Qiang, resurtm)
+- Enh #1391: CDetailView: callables (including anonymous functions for PHP 5.3+) could be used as value generators of the attributes (resurtm)
- Enh #1396: Added 'text/csv' mime-type for the 'csv' file extension in utils/mimeTypes.php (effectively used by e.g. CHttpRequest::sendFile()) (rawtaz)
- Enh: Fixed the check for ajaxUpdate false value in jquery.yiilistview.js as that never happens (mdomba)
- Enh: Requirements checker: added check for Oracle database (pdo_oci extension) and MSSQL (pdo_dblib, pdo_sqlsrv and pdo_mssql extensions) (resurtm)
6 framework/zii/widgets/CDetailView.php
@@ -77,7 +77,9 @@ class CDetailView extends CWidget
* If the below "value" element is specified, this will be ignored.</li>
* <li>value: the value to be displayed. If this is not specified, the above "name" element will be used
* to retrieve the corresponding attribute value for display. Note that this value will be formatted according
- * to the "type" option as described below.</li>
+ * to the "type" option as described below. Callables and anonymous functions (PHP 5.3+ only) could be
+ * used for calculating value since 1.1.13. Your callback should be able to receive single parameter, the data
+ * object of the detail view.</li>
* <li>type: the type of the attribute that determines how the attribute value would be formatted.
* Please see above for possible values.
* <li>cssClass: the CSS class to be used for this item. This option is available since version 1.1.3.</li>
@@ -206,7 +208,7 @@ public function run()
- $value=$attribute['value'];
+ $value=is_string($attribute['value']) ? $attribute['value'] : call_user_func($attribute['value'],$this->data);
else if(isset($attribute['name']))

0 comments on commit c993457

Please sign in to comment.
Something went wrong with that request. Please try again.