Browse Source

Fixed EntityContext modifying query objects, closes #8519

While this is not the right fix for the issue, it is the easiest one for now
Jose Lorenzo Rodriguez 10 years ago
parent
commit
422d16ddc9
1 changed files with 8 additions and 2 deletions
  1. 8 2
      src/View/Form/EntityContext.php

+ 8 - 2
src/View/Form/EntityContext.php

@@ -120,7 +120,10 @@ class EntityContext implements ContextInterface
         $entity = $this->_context['entity'];
         if (empty($table)) {
             if (is_array($entity) || $entity instanceof Traversable) {
-                $entity = (new Collection($entity))->first();
+                foreach ($entity as $e) {
+                    $entity = $e;
+                    break;
+                }
             }
             $isEntity = $entity instanceof EntityInterface;
 
@@ -187,7 +190,10 @@ class EntityContext implements ContextInterface
     {
         $entity = $this->_context['entity'];
         if (is_array($entity) || $entity instanceof Traversable) {
-            $entity = (new Collection($entity))->first();
+            foreach ($entity as $e) {
+                $entity = $e;
+                break;
+            }
         }
         if ($entity instanceof EntityInterface) {
             return $entity->isNew() !== false;