Skip to content

Commit

Permalink
Revert "Fixed yiisoft#11973: `yii\helpers\BaseHtml::getAttributeValue…
Browse files Browse the repository at this point in the history
…()` fixed to work with `items[]` notation correctly"

This reverts commit 3fcc269.
  • Loading branch information
SilverFire committed Sep 11, 2016
1 parent 86b73bd commit c66b845
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
2 changes: 1 addition & 1 deletion framework/helpers/BaseHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ public static function getAttributeValue($model, $attribute)
}
$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];
Expand Down
15 changes: 0 additions & 15 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1026,21 +1026,6 @@ public function testCsrfDisable()
$noCsrfForm = Html::beginForm('/index.php', 'post', ['csrf' => false, 'id' => 'myform']);
$this->assertEquals('<form id="myform" action="/index.php" method="post">', $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]'));
}
}

/**
Expand Down

0 comments on commit c66b845

Please sign in to comment.