Added braces check for initDefaultButton (#12863)

This commit is contained in:
Edgard Lorraine Messias
2016-10-27 19:22:11 -02:00
committed by Alexander Makarov
parent aa6d34a285
commit d3c7accc49
2 changed files with 7 additions and 1 deletions

View File

@ -157,7 +157,7 @@ class ActionColumn extends Column
*/ */
protected function initDefaultButton($name, $iconName, $additionalOptions = []) 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) { $this->buttons[$name] = function ($url, $model, $key) use ($name, $iconName, $additionalOptions) {
$title = Yii::t('yii', ucfirst($name)); $title = Yii::t('yii', ucfirst($name));
$options = array_merge([ $options = array_merge([

View File

@ -24,6 +24,12 @@ class ActionColumnTest extends \yiiunit\TestCase
$column = new ActionColumn(['template' => '{show} {edit} {remove}']); $column = new ActionColumn(['template' => '{show} {edit} {remove}']);
$this->assertEmpty($column->buttons); $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() public function testRenderDataCell()