瀏覽代碼

Two Minor Bugfixes

First, if $name is a FieldDescription, ShowMapper now gets the string
representation ($name->getName()) and uses that, rather than the
object, as the array key.

Second, I replaced a call to getLabel(), which doesn't exist, with a
call to getOption('label').
Ethan Resnick 13 年之前
父節點
當前提交
0ae46920fd
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      Show/ShowMapper.php

+ 5 - 3
Show/ShowMapper.php

@@ -50,13 +50,15 @@ class ShowMapper
      * @return \Sonata\AdminBundle\Show\ShowMapper
      */
     public function add($name, $type = null, array $fieldDescriptionOptions = array())
-    {
+	{
         if (!$this->currentGroup) {
             $this->with($this->admin->getLabel());
         }
 
+        $fieldKey = ($name instanceof FieldDescriptionInterface) ? $name->getName() : $name;
+            
         $formGroups = $this->admin->getShowGroups();
-        $formGroups[$this->currentGroup]['fields'][$name] = $name;
+        $formGroups[$this->currentGroup]['fields'][$fieldKey] = $fieldKey;
         $this->admin->setShowGroups($formGroups);
 
 
@@ -73,7 +75,7 @@ class ShowMapper
             throw new \RuntimeException('invalid state');
         }
 
-        if (!$fieldDescription->getLabel()) {
+        if (!$fieldDescription->getOption('label')) {
             $fieldDescription->setOption('label', $this->admin->getLabelTranslatorStrategy()->getLabel($fieldDescription->getName(), 'show', 'label'));
         }