From d3c7accc4948fea7a189c8caa200bfa66771619d Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Thu, 27 Oct 2016 19:22:11 -0200 Subject: [PATCH] Added braces check for initDefaultButton (#12863) --- framework/grid/ActionColumn.php | 2 +- tests/framework/grid/ActionColumnTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/grid/ActionColumn.php b/framework/grid/ActionColumn.php index e4608d9b9ad..8194ed50068 100644 --- a/framework/grid/ActionColumn.php +++ b/framework/grid/ActionColumn.php @@ -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([ diff --git a/tests/framework/grid/ActionColumnTest.php b/tests/framework/grid/ActionColumnTest.php index 922373dceec..a40812dfe74 100644 --- a/tests/framework/grid/ActionColumnTest.php +++ b/tests/framework/grid/ActionColumnTest.php @@ -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()