Skip to content
Permalink
Browse files

Correctly handle field name for [] suffixed fields.

SecurityComponent was generating a different name for these fields. This
format matches the end result of `thing.prop[0]` as well, which is what
`thing.prop[]` is getting at.

Refs #8170
  • Loading branch information...
markstory committed Feb 5, 2016
1 parent 2d54b2a commit 8cc7d3841ea96d89bae652b791b9acb53cb6f09d
Showing with 6 additions and 2 deletions.
  1. +1 −1 src/View/Helper/FormHelper.php
  2. +5 −1 tests/TestCase/View/Helper/FormHelperTest.php
@@ -2435,7 +2435,7 @@ protected function _secureFieldName($name)
$parts = array_map(function ($el) {
return trim($el, ']');
}, $parts);
return $parts;
return array_filter($parts, 'strlen');
}
/**
@@ -1746,7 +1746,11 @@ public function testSecuredInputCustomName()
$this->Form->select('select_box', [1, 2], [
'name' => 'Option[General.select_role]',
]);
$expected = ['Option.General.default_role', 'Option.General.select_role'];
$expected[] = 'Option.General.select_role';
$this->assertEquals($expected, $this->Form->fields);
$this->Form->text('other.things[]');
$expected[] = 'other.things';
$this->assertEquals($expected, $this->Form->fields);
}

0 comments on commit 8cc7d38

Please sign in to comment.
You can’t perform that action at this time.