Explorar o código

avoid field being added twice

Thomas %!s(int64=14) %!d(string=hai) anos
pai
achega
d2073371c2
Modificáronse 2 ficheiros con 15 adicións e 0 borrados
  1. 11 0
      Admin/Admin.php
  2. 4 0
      Datagrid/ListCollection.php

+ 11 - 0
Admin/Admin.php

@@ -800,6 +800,11 @@ abstract class Admin extends ContainerAware
 
 
         foreach ($this->getFormFieldDescriptions() as $fieldDescription) {
         foreach ($this->getFormFieldDescriptions() as $fieldDescription) {
 
 
+            // do not add field already set in the configureFormField method
+            if($mapper->has($fieldDescription->getFieldName())) {
+                continue;
+            }
+
             $mapper->add($fieldDescription);
             $mapper->add($fieldDescription);
         }
         }
         
         
@@ -824,6 +829,12 @@ abstract class Admin extends ContainerAware
         $this->configureListFields($mapper);
         $this->configureListFields($mapper);
 
 
         foreach ($this->getListFieldDescriptions() as $fieldDescription) {
         foreach ($this->getListFieldDescriptions() as $fieldDescription) {
+
+            // do not add field already set in the configureFormField method
+            if($mapper->has($fieldDescription->getFieldName())) {
+                continue;
+            }
+
             $mapper->add($fieldDescription);
             $mapper->add($fieldDescription);
         }
         }
 
 

+ 4 - 0
Datagrid/ListCollection.php

@@ -28,5 +28,9 @@ class ListCollection
         return $this->elements;
         return $this->elements;
     }
     }
 
 
+    public function has($name)
+    {
+        return array_key_exists($name, $this->elements);
+    }
     
     
 }
 }