Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Commit

Permalink
Merge pull request #97 from JesseLeite/bugfix-unnecessary-array-filter
Browse files Browse the repository at this point in the history
Unnecessary array_filter?
  • Loading branch information
adamwathan committed May 10, 2016
2 parents 942f107 + 1cd183f commit 8056cea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AdamWathan/Form/Binding/BoundData.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function data()

protected function dotGet($dotKey, $default)
{
$keyParts = array_filter(explode('.', $dotKey));
$keyParts = explode('.', $dotKey);

return $this->dataGet($this->data, $keyParts, $default);
}
Expand Down
20 changes: 20 additions & 0 deletions tests/BindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,26 @@ public function testBindNestedArrayWithMissingKey()
$this->assertEquals($expected, $result);
}

public function testBindArrayWithZeroAsKey()
{
$array = [
'hotdog' => [
0 => 'Tube',
1 => 'Steak',
],
];

$this->form->bind($array);

$expected = '<input type="text" name="hotdog[0]" value="Tube">';
$result = (string) $this->form->text('hotdog[0]');
$this->assertEquals($expected, $result);

$expected = '<input type="text" name="hotdog[1]" value="Steak">';
$result = (string) $this->form->text('hotdog[1]');
$this->assertEquals($expected, $result);
}

public function testBindNestedObject()
{
$object = json_decode(json_encode([
Expand Down

0 comments on commit 8056cea

Please sign in to comment.