Browse Source

More work towards marking entities with their source

Jose Lorenzo Rodriguez 12 years ago
parent
commit
b83bea9669
2 changed files with 4 additions and 4 deletions
  1. 2 2
      src/ORM/ResultSet.php
  2. 2 2
      tests/TestCase/View/Helper/FormHelperTest.php

+ 2 - 2
src/ORM/ResultSet.php

@@ -381,11 +381,11 @@ class ResultSet implements Countable, Iterator, Serializable, JsonSerializable {
 			if (!isset($results[$alias])) {
 				continue;
 			}
-			$target = $instance->target();
 			$instance = $assoc['instance'];
+			$target = $instance->target();
 			$results[$alias] = $this->_castValues($target, $results[$alias]);
 			$options['source'] = [
-				'alias' => $instance->alias(),
+				'alias' => $target->alias(),
 				'className' => get_class($target)
 			];
 

+ 2 - 2
tests/TestCase/View/Helper/FormHelperTest.php

@@ -1691,7 +1691,7 @@ class FormHelperTest extends TestCase {
 		$nested = new Entity(['foo' => 'bar']);
 		$nested->errors('foo', ['not a valid bar']);
 		$entity = new Entity(['nested' => $nested]);
-		$this->Form->create($entity);
+		$this->Form->create($entity, ['context' => ['table' => 'Articles']]);
 
 		$result = $this->Form->error('nested.foo');
 		$this->assertEquals('<div class="error-message">not a valid bar</div>', $result);
@@ -1709,7 +1709,7 @@ class FormHelperTest extends TestCase {
 		$nested = new Entity(['foo' => $inner]);
 		$entity = new Entity(['nested' => $nested]);
 		$inner->errors('bar', ['not a valid one']);
-		$this->Form->create($entity);
+		$this->Form->create($entity, ['context' => ['table' => 'Articles']]);
 		$result = $this->Form->error('nested.foo.bar');
 		$this->assertEquals('<div class="error-message">not a valid one</div>', $result);
 	}