From dfc1014fba452a178cfb31e9693cb2d8c28d78d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 30 Oct 2009 00:15:31 -0430 Subject: [PATCH] Making current action be the default for new forms. Updating test accordingly. closes #5353 Signed-off-by: Mark Story --- cake/libs/view/helpers/form.php | 2 +- cake/tests/cases/libs/view/helpers/form.test.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 64bde2ebe..73915d738 100755 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -209,7 +209,7 @@ class FormHelper extends AppHelper { } } if (empty($options['action'])) { - $options['action'] = ($created) ? 'edit' : 'add'; + $options['action'] = $this->params['action']; } $actionDefaults = array( diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 919db63b2..9365d7082 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -666,6 +666,7 @@ class FormHelperTest extends CakeTestCase { $this->Form->Html =& new HtmlHelper(); $this->Controller =& new ContactTestController(); $this->View =& new View($this->Controller); + $this->Form->params['action'] = 'add'; ClassRegistry::addObject('view', $view); ClassRegistry::addObject('Contact', new Contact()); @@ -4669,6 +4670,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->data['Contact']['id'] = 1; + $this->Form->params['action'] = 'edit'; $result = $this->Form->create('Contact'); $expected = array( 'form' => array( @@ -4702,6 +4704,7 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); + $this->Form->params['action'] = 'add'; $result = $this->Form->create('User', array('url' => array('action' => 'login'))); $expected = array( 'form' => array('id' => 'UserAddForm', 'method' => 'post', 'action' => '/users/login/'), @@ -4841,7 +4844,7 @@ class FormHelperTest extends CakeTestCase { 'last_name' => 'Abele', 'email' => 'nate@example.com' )); - $this->Form->params = array('models' => array('Person'), 'controller' => 'people'); + $this->Form->params = array('models' => array('Person'), 'controller' => 'people', 'action' => 'add'); $options = array(1 => 'Nate', 2 => 'Garrett', 3 => 'Larry'); $this->Form->create();