Skip to content

Commit

Permalink
Added braces check for initDefaultButton (yiisoft#12863)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias authored and samdark committed Oct 27, 2016
1 parent aa6d34a commit d3c7acc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion framework/grid/ActionColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function initDefaultButtons()
*/
protected function initDefaultButton($name, $iconName, $additionalOptions = [])
{
if (!isset($this->buttons[$name]) && strpos($this->template, $name) !== false) {
if (!isset($this->buttons[$name]) && strpos($this->template, '{' . $name . '}') !== false) {
$this->buttons[$name] = function ($url, $model, $key) use ($name, $iconName, $additionalOptions) {
$title = Yii::t('yii', ucfirst($name));
$options = array_merge([
Expand Down
6 changes: 6 additions & 0 deletions tests/framework/grid/ActionColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public function testInit()

$column = new ActionColumn(['template' => '{show} {edit} {remove}']);
$this->assertEmpty($column->buttons);

$column = new ActionColumn(['template' => '{view-items} {update-items} {delete-items}']);
$this->assertEmpty($column->buttons);

$column = new ActionColumn(['template' => '{view} {view-items}']);
$this->assertEquals(['view'], array_keys($column->buttons));
}

public function testRenderDataCell()
Expand Down

0 comments on commit d3c7acc

Please sign in to comment.