From 75a499b0e28ce84b423f8876287d766d75f89511 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 10 May 2011 14:40:20 +0200 Subject: [PATCH] [Form] Fix the fluid interface of FormBuilder --- src/Symfony/Component/Form/Form.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 262102cce3..88605cd35e 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/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. * - * @see FormInterface + * @param FormError $error + * + * @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; } /**