Applying patch from 'dragonfly' to fix issue where FormHelper would always append an argument even if one was supplied.

Test Added
Fixes #1155
This commit is contained in:
mark_story 2010-10-13 21:36:05 -04:00
parent a0a84d1a8d
commit 3f2109f3c3
2 changed files with 34 additions and 2 deletions

View file

@ -256,13 +256,15 @@ class FormHelper extends AppHelper {
$actionDefaults = array(
'plugin' => $this->plugin,
'controller' => $view->viewPath,
'action' => $options['action'],
0 => $id
'action' => $options['action']
);
if (!empty($options['action']) && !isset($options['id'])) {
$options['id'] = $this->domId($options['action'] . 'Form');
}
$options['action'] = array_merge($actionDefaults, (array)$options['url']);
if (empty($options['action'][0])) {
$options['action'][0] = $id;
}
} elseif (is_string($options['url'])) {
$options['action'] = $options['url'];
}

View file

@ -5541,6 +5541,36 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected, true);
}
/**
* test that create() doesn't add in extra passed params.
*
* @return void
*/
function testCreatePassedArgs() {
$encoding = strtolower(Configure::read('App.encoding'));
$this->Form->data['Contact']['id'] = 1;
$result = $this->Form->create('Contact', array(
'type' => 'post',
'escape' => false,
'url' => array(
'action' => 'edit',
'myparam'
)
));
$expected = array(
'form' => array(
'id' => 'ContactAddForm',
'method' => 'post',
'action' => '/contacts/edit/myparam',
'accept-charset' => $encoding
),
'div' => array('style' => 'display:none;'),
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
'/div'
);
$this->assertTags($result, $expected, true);
}
/**
* test creating a get form, and get form inputs.
*