فهرست منبع

Fix error with form

Thomas Rabaix 12 سال پیش
والد
کامیت
df240bf2fc
2فایلهای تغییر یافته به همراه8 افزوده شده و 12 حذف شده
  1. 7 3
      Form/Type/AdminType.php
  2. 1 9
      Form/Type/CollectionType.php

+ 7 - 3
Form/Type/AdminType.php

@@ -45,16 +45,20 @@ class AdminType extends AbstractType
      */
     public function setDefaultOptions(OptionsResolverInterface $resolver)
     {
-        $resolver->setDefaults(array('delete' => true));
+        $resolver->setDefaults(array(
+            'delete' => true,
+            'auto_initialize' => false
+        ));
     }
 
     /**
      * @param array $options
      *
      * @return \Sonata\AdminBundle\Admin\FieldDescriptionInterface
+     *
      * @throws \RuntimeException
      */
-    public function getFieldDescription(array $options)
+    protected function getFieldDescription(array $options)
     {
         if (!isset($options['sonata_field_description'])) {
             throw new \RuntimeException('Please provide a valid `sonata_field_description` option');
@@ -68,7 +72,7 @@ class AdminType extends AbstractType
      *
      * @return \Sonata\AdminBundle\Admin\AdminInterface
      */
-    public function getAdmin(array $options)
+    protected function getAdmin(array $options)
     {
         return $this->getFieldDescription($options)->getAssociationAdmin();
     }

+ 1 - 9
Form/Type/CollectionType.php

@@ -36,14 +36,6 @@ class CollectionType extends AbstractType
         $builder->addEventSubscriber($listener);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public function getParent()
-    {
-        return 'field';
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -52,7 +44,7 @@ class CollectionType extends AbstractType
         $resolver->setDefaults(array(
             'modifiable'    => false,
             'type'          => 'text',
-            'type_options'  => array()
+            'type_options'  => array(),
         ));
     }