Skip to content
Permalink
Browse files

Allow creating form tag without "action" attribute.

Closes #6488
  • Loading branch information...
ADmad committed May 5, 2015
1 parent d6c54d8 commit 911aafa7c73630aeb06e2e0f265ffa1c4ea060db
Showing with 29 additions and 4 deletions.
  1. +9 −4 src/View/Helper/FormHelper.php
  2. +20 −0 tests/TestCase/View/Helper/FormHelperTest.php
@@ -367,11 +367,16 @@ public function create($model = null, array $options = [])
}
unset($options['templates']);
$url = $this->_formUrl($context, $options);
$action = $this->Url->build($url);
unset($options['url'], $options['action'], $options['idPrefix']);
if ($options['url'] === false) {
$action = null;
$this->_lastAction = '';
} else {
$url = $this->_formUrl($context, $options);
$action = $this->Url->build($url);
$this->_lastAction($url);
$this->_lastAction($url);
}
unset($options['url'], $options['action'], $options['idPrefix']);
$htmlAttributes = [];
switch (strtolower($options['type'])) {
@@ -673,6 +673,26 @@ public function testCreateAutoUrl()
$this->assertHtml($expected, $result);
}
/**
* test create() with no url (no "action" attribute for <form> tag)
*
* @return void
*/
public function testCreateNoUrl()
{
$result = $this->Form->create(false, ['url' => false]);
$expected = [
'form' => [
'method' => 'post',
'accept-charset' => strtolower(Configure::read('App.encoding'))
],
'div' => ['style' => 'display:none;'],
'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'],
'/div'
];
$this->assertHtml($expected, $result);
}
/**
* test create() with a custom route
*

0 comments on commit 911aafa

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