Fix FormHelper::create() dropping 0 value parameter.

When 0 is the first passed parameter we shouldn't drop it.

Fixes #6107
This commit is contained in:
mark_story 2015-03-19 21:15:20 -04:00
parent af65067b50
commit 744952e344
2 changed files with 5 additions and 4 deletions

View file

@ -8642,6 +8642,7 @@ class FormHelperTest extends CakeTestCase {
'escape' => false,
'url' => array(
'action' => 'edit',
'0',
'myparam'
)
));
@ -8649,7 +8650,7 @@ class FormHelperTest extends CakeTestCase {
'form' => array(
'id' => 'ContactAddForm',
'method' => 'post',
'action' => '/contacts/edit/myparam',
'action' => '/contacts/edit/0/myparam',
'accept-charset' => $encoding
),
'div' => array('style' => 'display:none;'),
@ -8667,8 +8668,8 @@ class FormHelperTest extends CakeTestCase {
public function testCreateNoErrorsWithMockModel() {
$encoding = strtolower(Configure::read('App.encoding'));
$ContactMock = $this->getMockBuilder('Contact')
->disableOriginalConstructor()
->getMock();
->disableOriginalConstructor()
->getMock();
ClassRegistry::removeObject('Contact');
ClassRegistry::addObject('Contact', $ContactMock);
$result = $this->Form->create('Contact', array('type' => 'GET'));

View file

@ -408,7 +408,7 @@ class FormHelper extends AppHelper {
'action' => $options['action'],
);
$options['action'] = array_merge($actionDefaults, (array)$options['url']);
if (empty($options['action'][0]) && !empty($id)) {
if (!isset($options['action'][0]) && !empty($id)) {
$options['action'][0] = $id;
}
} elseif (is_string($options['url'])) {