浏览代码

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 年之前
父节点
当前提交
d0a310aad5
共有 1 个文件被更改,包括 4 次插入1 次删除
  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()));
     }