diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 4f71b99..735950a 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -2043,7 +2043,7 @@ class BaseHtml } $attribute = $matches[2]; $value = $model->$attribute; - if ($matches[3] !== '' && $matches[3] !== '[]') { + if ($matches[3] !== '') { foreach (explode('][', trim($matches[3], '[]')) as $id) { if ((is_array($value) || $value instanceof \ArrayAccess) && isset($value[$id])) { $value = $value[$id]; diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index df37057..0c23701 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -1026,21 +1026,6 @@ EOD; $noCsrfForm = Html::beginForm('/index.php', 'post', ['csrf' => false, 'id' => 'myform']); $this->assertEquals('
', $noCsrfForm); } - - public function testGetAttributeValue() - { - $model = new HtmlTestModel(); - $model->types = ['type1', 'type2', ['sub-array', 'sub-array2']]; - - $this->assertEquals($model->types, Html::getAttributeValue($model, 'types')); - $this->assertEquals($model->types, Html::getAttributeValue($model, 'types[]')); - $this->assertEquals('type1', Html::getAttributeValue($model, 'types[0]')); - $this->assertEquals('type2', Html::getAttributeValue($model, 'types[1]')); - $this->assertEquals('type2', Html::getAttributeValue($model, 'types[1][]')); - $this->assertEquals(['sub-array', 'sub-array2'], Html::getAttributeValue($model, 'types[2][]')); - $this->assertEquals('sub-array2', Html::getAttributeValue($model, 'types[2][1]')); - $this->assertEquals(null, Html::getAttributeValue($model, 'types[3]')); - } } /**