Browse Source

Fix Form Component

Thomas Rabaix 13 năm trước cách đây
mục cha
commit
902b9ef9ff
2 tập tin đã thay đổi với 4 bổ sung9 xóa
  1. 2 7
      Form/Type/ModelTypeList.php
  2. 2 2
      Util/FormViewIterator.php

+ 2 - 7
Form/Type/ModelTypeList.php

@@ -43,15 +43,10 @@ class ModelTypeList extends AbstractType
      */
     public function buildView(FormView $view, FormInterface $form, array $options)
     {
-        if ($view->hasVar('sonata_admin')) {
-            $parameters = $view->getVar('sonata_admin');
-
+        if (isset($view->vars['sonata_admin'])) {
             // set the correct edit mode
-            $parameters['edit'] = 'list';
-
-            $view->setVar('sonata_admin', $parameters);
+            $view->vars['sonata_admin']['edit'] = 'list';
         }
-
     }
 
     /**

+ 2 - 2
Util/FormViewIterator.php

@@ -37,7 +37,7 @@ class FormViewIterator implements \RecursiveIterator
      */
     public function hasChildren()
     {
-        return $this->current()->hasChildren();
+        return count($this->current()->children) > 0;
     }
 
     /**
@@ -61,7 +61,7 @@ class FormViewIterator implements \RecursiveIterator
      */
     public function key()
     {
-        return $this->current()->getVar('id');
+        return $this->current()->vars['id'];
     }
 
     /**