Browse Source

Enable public fields without getters to be displayed

Enable public fields without getters to be displayed in the list.
Previously, when there was not getter method, the field would not have a value in the list, even if it was public. Forms would still work because they use the Symfony2 Form mechanisms that look for getters first and then for public fields.
Michel Weimerskirch 12 years ago
parent
commit
d0a310aad5
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Admin/BaseFieldDescription.php

+ 4 - 1
Admin/BaseFieldDescription.php

@@ -322,13 +322,16 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
         $getters[] = 'get' . $camelizedFieldName;
         $getters[] = 'is' . $camelizedFieldName;
 
-
         foreach ($getters as $getter) {
             if (method_exists($object, $getter)) {
                 return call_user_func(array($object, $getter));
             }
         }
 
+        if (isset($object->{$fieldName})) {
+            return $object->{$fieldName};
+        }
+
         throw new NoValueException(sprintf('Unable to retrieve the value of `%s`', $this->getName()));
     }