Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applying patch from 'dragonfly' to fix issue where FormHelper would a…

…lways append an argument even if one was supplied.

Test Added
Fixes #1155
  • Loading branch information...
commit 3f2109f3c363680cfebb9e86c1f63101a62d216f 1 parent a0a84d1
@markstory markstory authored
View
6 cake/libs/view/helpers/form.php
@@ -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'];
}
View
30 cake/tests/cases/libs/view/helpers/form.test.php
@@ -5542,6 +5542,36 @@ function testCreateQuerystringParams() {
}
/**
+ * 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.
*
* @access public
Please sign in to comment.
Something went wrong with that request. Please try again.