Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
5c79ab20
Commit
5c79ab20
authored
Aug 06, 2014
by
disem
Committed by
Carsten Brandt
Aug 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added key param to ActionColumn button Closure
fixes #4602, close #4624
parent
689fc137
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
ActionColumn.php
framework/grid/ActionColumn.php
+5
-5
No files found.
framework/CHANGELOG.md
View file @
5c79ab20
...
...
@@ -171,6 +171,7 @@ Yii Framework 2 Change Log
-
Enh #4559: Added
`beforeValidateAll`
and
`afterValidateAll`
callbacks to
`ActiveForm`
(Alex-Code)
-
Enh #4566: Added client validation support for image validator (Skysplit, qiangxue)
-
Enh #4581: Added ability to disable url encoding in
`UrlRule`
(tadaszelvys)
-
Enh #4602: Added $key param in ActionColumn buttons Closure call (disem)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
-
Enh: Added
`yii\web\UrlManager::addRules()`
to simplify adding new URL rules (qiangxue)
...
...
framework/grid/ActionColumn.php
View file @
5c79ab20
...
...
@@ -54,20 +54,20 @@ class ActionColumn extends Column
* signature:
*
* ```php
* function ($url, $model) {
* function ($url, $model
, $key
) {
* // return the button HTML code
* }
* ```
*
* where `$url` is the URL that the column creates for the button,
and
`$model` is the model object
* being rendered for the current row.
* where `$url` is the URL that the column creates for the button, `$model` is the model object
* being rendered for the current row
, and `$key` is the key of the model in the data provider array
.
*
* You can add further conditions to the button, for example only display it, when the model is
* editable (here assuming you have a status field that indicates that):
*
* ```php
* [
* 'update' => function ($url, $model) {
* 'update' => function ($url, $model
, $key
) {
* return $model->status == 'editable' ? Html::a('Update', $url) : '';
* };
* ],
...
...
@@ -155,7 +155,7 @@ class ActionColumn extends Column
if
(
isset
(
$this
->
buttons
[
$name
]))
{
$url
=
$this
->
createUrl
(
$name
,
$model
,
$key
,
$index
);
return
call_user_func
(
$this
->
buttons
[
$name
],
$url
,
$model
);
return
call_user_func
(
$this
->
buttons
[
$name
],
$url
,
$model
,
$key
);
}
else
{
return
''
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment