Browse Source

Fixed double encoding of form url.

ADmad 12 years ago
parent
commit
352171931c
2 changed files with 6 additions and 16 deletions
  1. 6 6
      src/View/Helper/FormHelper.php
  2. 0 10
      tests/TestCase/View/Helper/FormHelperTest.php

+ 6 - 6
src/View/Helper/FormHelper.php

@@ -331,9 +331,10 @@ class FormHelper extends Helper {
 			'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 @@ class FormHelper extends Helper {
 		}
 		$this->requestType = strtolower($options['type']);
 
-		$htmlAttributes['action'] = $this->url($options['action']);
-
 		if (!$options['default']) {
 			if (!isset($options['onsubmit'])) {
 				$options['onsubmit'] = '';
@@ -368,7 +367,7 @@ class FormHelper extends Helper {
 		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 @@ class FormHelper extends Helper {
 		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;
 	}
 

+ 0 - 10
tests/TestCase/View/Helper/FormHelperTest.php

@@ -977,16 +977,6 @@ class FormHelperTest extends TestCase {
 				'?' => 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);
 	}