Browse Source

avoid field being added twice

Thomas 14 years ago
parent
commit
d2073371c2
2 changed files with 15 additions and 0 deletions
  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) {
 
+            // do not add field already set in the configureFormField method
+            if($mapper->has($fieldDescription->getFieldName())) {
+                continue;
+            }
+
             $mapper->add($fieldDescription);
         }
         
@@ -824,6 +829,12 @@ abstract class Admin extends ContainerAware
         $this->configureListFields($mapper);
 
         foreach ($this->getListFieldDescriptions() as $fieldDescription) {
+
+            // do not add field already set in the configureFormField method
+            if($mapper->has($fieldDescription->getFieldName())) {
+                continue;
+            }
+
             $mapper->add($fieldDescription);
         }
 

+ 4 - 0
Datagrid/ListCollection.php

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