Skip to content

Commit

Permalink
Making current action be the default for new forms. Updating test acc…
Browse files Browse the repository at this point in the history
…ordingly. closes #5353

Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information
lorenzo authored and markstory committed Oct 31, 2009
1 parent 55fc72c commit dfc1014
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/form.php
Expand Up @@ -209,7 +209,7 @@ function create($model = null, $options = array()) {
}
}
if (empty($options['action'])) {
$options['action'] = ($created) ? 'edit' : 'add';
$options['action'] = $this->params['action'];
}

$actionDefaults = array(
Expand Down
5 changes: 4 additions & 1 deletion cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -666,6 +666,7 @@ function setUp() {
$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());
Expand Down Expand Up @@ -4669,6 +4670,7 @@ function testFormCreate() {
$this->assertTags($result, $expected);

$this->Form->data['Contact']['id'] = 1;
$this->Form->params['action'] = 'edit';
$result = $this->Form->create('Contact');
$expected = array(
'form' => array(
Expand Down Expand Up @@ -4702,6 +4704,7 @@ function testFormCreate() {
);
$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/'),
Expand Down Expand Up @@ -4841,7 +4844,7 @@ function testEditFormWithData() {
'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();
Expand Down

0 comments on commit dfc1014

Please sign in to comment.