Skip to content

Commit

Permalink
Account for input named '0'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Mar 29, 2015
1 parent 12b4cea commit e327509
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/View/Helper/FormHelper.php
Expand Up @@ -617,7 +617,7 @@ public function unlockField($name = null)
*/
protected function _secure($lock, $field, $value = null)
{
if (empty($field)) {
if (empty($field) && $field !== '0') {
return;
}

Expand Down Expand Up @@ -2390,7 +2390,7 @@ protected function _initInputField($field, $options = [])
*/
protected function _secureFieldName($name)
{
if (empty($name)) {
if (empty($name) && $name !== '0') {
return [];
}

Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -275,6 +275,10 @@ public function testRenderingWidgetWithEmptyName()
$result = $this->Form->widget('select', ['secure' => true, 'name' => '']);
$this->assertEquals('<select name=""></select>', $result);
$this->assertEquals([], $this->Form->fields);

$result = $this->Form->widget('select', ['secure' => true, 'name' => '0']);
$this->assertEquals('<select name="0"></select>', $result);
$this->assertEquals(['0'], $this->Form->fields);
}

/**
Expand Down

0 comments on commit e327509

Please sign in to comment.