Skip to content
Permalink
Browse files

Add the ability to read value from an array entity context

  • Loading branch information...
dakota committed Jul 13, 2015
1 parent d823fad commit d0c778a858770efaf9dba4ab90d425534ecc2317
Showing with 8 additions and 0 deletions.
  1. +2 −0 src/View/Form/EntityContext.php
  2. +6 −0 tests/TestCase/View/Form/EntityContextTest.php
@@ -222,6 +222,8 @@ public function val($field)
if ($entity instanceof EntityInterface) {
return $entity->get(array_pop($parts));
} elseif (is_array($entity)) {
return $entity[array_pop($parts)];
}
return null;
}
@@ -458,6 +458,9 @@ public function testValGetArrayValue()
$row = new Article([
'title' => 'Test entity',
'types' => [1, 2, 3],
'tag' => [
'name' => 'Test tag',
],
'author' => new Entity([
'roles' => ['admin', 'publisher']
])
@@ -471,6 +474,9 @@ public function testValGetArrayValue()
$result = $context->val('author.roles');
$this->assertEquals($row->author->roles, $result);
$result = $context->val('tag.name');
$this->assertEquals($row->tag['name'], $result);
}
/**

3 comments on commit d0c778a

@daniouyea

This comment has been minimized.

Copy link

replied Jul 18, 2015

This change brings me this Notice (8): Undefined index: _ids [CORE/src/View/Form/EntityContext.php, line 226] when the belongsToMany relationship is empty.

@markstory

This comment has been minimized.

Copy link
Member

replied Jul 19, 2015

@daniouyea Could you open an issue with how to reproduce the problem you're having? Commit comments are easily lost/forgotten.

@ricog

This comment has been minimized.

Copy link
Contributor

replied Jul 24, 2015

This is resolved in 3.0.10 by #7064

Please sign in to comment.
You can’t perform that action at this time.