Skip to content

Commit

Permalink
Fix isCreate()
Browse files Browse the repository at this point in the history
It was backwards.
  • Loading branch information
markstory committed Feb 10, 2014
1 parent 9a54547 commit c31c9a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/View/Form/ArrayContext.php
Expand Up @@ -121,7 +121,7 @@ public function primaryKey() {
public function isCreate() {
$primary = $this->primaryKey();
foreach ($primary as $column) {
if (!isset($this->_context['defaults'][$column])) {
if (!empty($this->_context['defaults'][$column])) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Form/ArrayContextTest.php
Expand Up @@ -79,11 +79,11 @@ public function testIsCreate() {
],
];
$context = new ArrayContext($this->request, $data);
$this->assertFalse($context->isCreate());
$this->assertTrue($context->isCreate());

$data['defaults'] = ['id' => 2];
$context = new ArrayContext($this->request, $data);
$this->assertTrue($context->isCreate());
$this->assertFalse($context->isCreate());
}

/**
Expand Down

0 comments on commit c31c9a0

Please sign in to comment.