mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
a0a84d1a8d
commit
3f2109f3c3
2 changed files with 34 additions and 2 deletions
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue