Victor Berchet 14 роки тому
батько
коміт
99bf22c464

+ 1 - 1
src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php

@@ -24,7 +24,7 @@ class CollectionType extends AbstractType
         if ($options['allow_add'] && $options['prototype']) {
             $builder->add('$$name$$', $options['type'], array_replace(array(
                 'property_path' => false,
-                'required' => false,
+                'required'      => false,
             ), $options['options']));
         }
 

+ 7 - 4
src/Symfony/Component/Form/Extension/Core/Type/FileType.php

@@ -50,15 +50,18 @@ class FileType extends AbstractType
 
     public function buildViewBottomUp(FormView $view, FormInterface $form)
     {
-        $view->set('multipart', true);
-        $view['file']->set('type', 'file');
-        $view['file']->set('value', '');
+        $view
+            ->set('multipart', true)
+            ->getChild('file')
+                ->set('type', 'file')
+                ->set('value', '')
+        ;
     }
 
     public function getDefaultOptions(array $options)
     {
         return array(
-            'type'              => 'string',
+            'type' => 'string',
         );
     }
 

+ 4 - 2
src/Symfony/Component/Form/Extension/Core/Type/FormType.php

@@ -21,8 +21,10 @@ class FormType extends AbstractType
 {
     public function buildForm(FormBuilder $builder, array $options)
     {
-        $builder->setAttribute('virtual', $options['virtual'])
-            ->setDataMapper(new PropertyPathMapper($options['data_class']));
+        $builder
+            ->setAttribute('virtual', $options['virtual'])
+            ->setDataMapper(new PropertyPathMapper($options['data_class']))
+        ;
     }
 
     public function buildViewBottomUp(FormView $view, FormInterface $form)

+ 13 - 1
src/Symfony/Component/Form/FormView.php

@@ -185,6 +185,18 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
         return $this->children;
     }
 
+    /**
+     * Returns a given child.
+     *
+     * @param string name The name of the child
+     *
+     * @return FormView The child view
+     */
+    public function getChild($name)
+    {
+        return $this->children[$name];
+    }
+
     /**
      * Returns whether this view has children.
      *
@@ -204,7 +216,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
      */
     public function offsetGet($name)
     {
-        return $this->children[$name];
+        return $this->getChild($name);
     }
 
     /**