Skip to content
Permalink
Browse files

Fixed double encoding of form url.

  • Loading branch information...
ADmad committed Feb 19, 2014
1 parent ebc629b commit 352171931cdfce30b793d4e45eb1ef42d553b352
Showing with 6 additions and 16 deletions.
  1. +6 −6 src/View/Helper/FormHelper.php
  2. +0 −10 tests/TestCase/View/Helper/FormHelperTest.php
@@ -331,9 +331,10 @@ public function create($model = null, $options = []) {
'encoding' => strtolower(Configure::read('App.encoding')),
];
$options['action'] = $this->_formUrl($context, $options);
unset($options['url']);
$action = $this->url($this->_formUrl($context, $options));
unset($options['url'], $options['action']);
$htmlAttributes = [];
switch (strtolower($options['type'])) {
case 'get':
$htmlAttributes['method'] = 'get';
@@ -356,8 +357,6 @@ public function create($model = null, $options = []) {
}
$this->requestType = strtolower($options['type']);
$htmlAttributes['action'] = $this->url($options['action']);
if (!$options['default']) {
if (!isset($options['onsubmit'])) {
$options['onsubmit'] = '';
@@ -368,7 +367,7 @@ public function create($model = null, $options = []) {
if (!empty($options['encoding'])) {
$htmlAttributes['accept-charset'] = $options['encoding'];
}
unset($options['type'], $options['action'], $options['encoding'], $options['default']);
unset($options['type'], $options['encoding'], $options['default']);
$htmlAttributes = array_merge($options, $htmlAttributes);
@@ -380,8 +379,9 @@ public function create($model = null, $options = []) {
if (!empty($append)) {
$append = $this->formatTemplate('hiddenblock', ['content' => $append]);
}
$actionAttr = $this->_templater->formatAttributes(['action' => $action, 'escape' => false]);
return $this->formatTemplate('formstart', [
'attrs' => $this->_templater->formatAttributes($htmlAttributes)
'attrs' => $this->_templater->formatAttributes($htmlAttributes) . $actionAttr
]) . $append;
}
@@ -977,16 +977,6 @@ public function testCreateQuerystringrequest() {
'?' => array('param1' => 'value1', 'param2' => 'value2')
)
));
$expected = array(
'form' => array(
'method' => 'post',
'action' => '/controller/action?param1=value1&param2=value2',
'accept-charset' => $encoding
),
'div' => array('style' => 'display:none;'),
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
'/div'
);
$this->assertTags($result, $expected);
}

0 comments on commit 3521719

Please sign in to comment.
You can’t perform that action at this time.