mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Fixing issue where a false id would be appended to the route url. Test added. Fixes #1501
This commit is contained in:
parent
5b8499c8c7
commit
63308fdbd8
2 changed files with 24 additions and 4 deletions
|
@ -260,7 +260,7 @@ class FormHelper extends AppHelper {
|
||||||
$options['id'] = $this->domId($options['action'] . 'Form');
|
$options['id'] = $this->domId($options['action'] . 'Form');
|
||||||
}
|
}
|
||||||
$options['action'] = array_merge($actionDefaults, (array)$options['url']);
|
$options['action'] = array_merge($actionDefaults, (array)$options['url']);
|
||||||
if (empty($options['action'][0])) {
|
if (empty($options['action'][0]) && !empty($id)) {
|
||||||
$options['action'][0] = $id;
|
$options['action'][0] = $id;
|
||||||
}
|
}
|
||||||
} elseif (is_string($options['url'])) {
|
} elseif (is_string($options['url'])) {
|
||||||
|
|
|
@ -661,8 +661,6 @@ class FormHelperTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Router::reload();
|
|
||||||
|
|
||||||
|
|
||||||
$this->Controller = new ContactTestController();
|
$this->Controller = new ContactTestController();
|
||||||
$this->View = new View($this->Controller);
|
$this->View = new View($this->Controller);
|
||||||
|
@ -703,7 +701,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
ClassRegistry::flush();
|
parent::tearDown();
|
||||||
unset($this->Form->Html, $this->Form, $this->Controller, $this->View);
|
unset($this->Form->Html, $this->Form, $this->Controller, $this->View);
|
||||||
Configure::write('Security.salt', $this->oldSalt);
|
Configure::write('Security.salt', $this->oldSalt);
|
||||||
}
|
}
|
||||||
|
@ -5640,6 +5638,28 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test create() with a custom route
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testCreateCustomRoute() {
|
||||||
|
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
|
||||||
|
$encoding = strtolower(Configure::read('App.encoding'));
|
||||||
|
|
||||||
|
$result = $this->Form->create('User', array('action' => 'login'));
|
||||||
|
$expected = array(
|
||||||
|
'form' => array(
|
||||||
|
'id' => 'UserLoginForm', 'method' => 'post', 'action' => '/login',
|
||||||
|
'accept-charset' => $encoding
|
||||||
|
),
|
||||||
|
'div' => array('style' => 'display:none;'),
|
||||||
|
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that inputDefaults are stored and used.
|
* test that inputDefaults are stored and used.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue