Skip to content

Commit

Permalink
Applying patch from 'dragonfly' to fix issue where FormHelper would a…
Browse files Browse the repository at this point in the history
…lways append an argument even if one was supplied.

Test Added
Fixes #1155
  • Loading branch information
markstory committed Oct 14, 2010
1 parent a0a84d1 commit 3f2109f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cake/libs/view/helpers/form.php
Expand Up @@ -256,13 +256,15 @@ function create($model = null, $options = array()) {
$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'];
}
Expand Down
30 changes: 30 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -5541,6 +5541,36 @@ function testCreateQuerystringParams() {
$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.
*
Expand Down

0 comments on commit 3f2109f

Please sign in to comment.