Browse Source

[Form] Fix the fluid interface of FormBuilder

Victor Berchet 14 years ago
parent
commit
75a499b0e2
1 changed files with 19 additions and 3 deletions
  1. 19 3
      src/Symfony/Component/Form/Form.php

+ 19 - 3
src/Symfony/Component/Form/Form.php

@@ -558,6 +558,8 @@ class Form implements \IteratorAggregate, FormInterface
         foreach ($this->validators as $validator) {
             $validator->validate($this);
         }
+
+        return $this;
     }
 
     /**
@@ -568,6 +570,8 @@ class Form implements \IteratorAggregate, FormInterface
      *
      * @param Request $request    The request to bind to the form
      *
+     * @return Form This form
+     *
      * @throws FormException if the method of the request is not one of GET, POST or PUT
      */
     public function bindRequest(Request $request)
@@ -588,7 +592,7 @@ class Form implements \IteratorAggregate, FormInterface
                 throw new FormException(sprintf('The request method "%s" is not supported', $request->getMethod()));
         }
 
-        $this->bind($data);
+        return $this->bind($data);
     }
 
     /**
@@ -604,9 +608,11 @@ class Form implements \IteratorAggregate, FormInterface
     }
 
     /**
-     * Adds an error to the field.
+     * Adds an error to this form.
+     *
+     * @param FormError $error
      *
-     * @see FormInterface
+     * @return Form The current form
      */
     public function addError(FormError $error)
     {
@@ -615,6 +621,8 @@ class Form implements \IteratorAggregate, FormInterface
         } else {
             $this->errors[] = $error;
         }
+
+        return $this;
     }
 
     /**
@@ -754,6 +762,8 @@ class Form implements \IteratorAggregate, FormInterface
      * Adds a child to the form.
      *
      * @param FormInterface $child The FormInterface to add as a child
+     *
+     * @return Form the current form
      */
     public function add(FormInterface $child)
     {
@@ -764,12 +774,16 @@ class Form implements \IteratorAggregate, FormInterface
         if ($this->dataMapper) {
             $this->dataMapper->mapDataToForm($this->getClientData(), $child);
         }
+
+        return $this;
     }
 
     /**
      * Removes a child from the form.
      *
      * @param string $name The name of the child to remove
+     *
+     * @return Form the current form
      */
     public function remove($name)
     {
@@ -778,6 +792,8 @@ class Form implements \IteratorAggregate, FormInterface
 
             unset($this->children[$name]);
         }
+
+        return $this;
     }
 
     /**