Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Form] Renamed submit() to bind()

  • Loading branch information...
commit 55a12a9cc13209254c04baa2729994a05b10900e 1 parent c9e862d
@webmozart webmozart authored
View
2  CsrfProvider/CsrfProviderInterface.php
@@ -22,7 +22,7 @@
*
* If you want to secure a form submission against CSRF attacks, you could
* use the class name of the form as page ID. This way you make sure that the
- * form can only be submitted to pages that are designed to handle the form,
+ * form can only be bound to pages that are designed to handle the form,
* that is, that use the same class name to validate the CSRF token with
* isCsrfTokenValid().
*
View
2  Exception/AlreadySubmittedException.php → Exception/AlreadyBoundException.php
@@ -11,6 +11,6 @@
namespace Symfony\Component\Form\Exception;
-class AlreadySubmittedException extends FormException
+class AlreadyBoundException extends FormException
{
}
View
28 Field.php
@@ -57,7 +57,7 @@ class Field implements FieldInterface
private $errors = array();
private $name = '';
private $parent;
- private $submitted = false;
+ private $bound = false;
private $required;
private $data;
private $normalizedData;
@@ -275,7 +275,7 @@ public function setData($appData)
*
* @param string|array $data The POST data
*/
- public function submit($clientData)
+ public function bind($clientData)
{
if (is_scalar($clientData) || null === $clientData) {
$clientData = (string)$clientData;
@@ -287,7 +287,7 @@ public function submit($clientData)
$appData = null;
$normData = null;
- // Hook to change content of the data submitted by the browser
+ // Hook to change content of the data bound by the browser
$event = new FilterDataEvent($clientData);
$this->dispatcher->dispatchEvent(Events::filterBoundDataFromClient, $event);
$clientData = $event->getData();
@@ -312,7 +312,7 @@ public function submit($clientData)
$clientData = $this->transform($normData);
}
- $this->submitted = true;
+ $this->bound = true;
$this->errors = array();
$this->data = $appData;
$this->normalizedData = $normData;
@@ -335,8 +335,8 @@ public function getData()
/**
* Returns the normalized data of the field.
*
- * @return mixed When the field is not submitted, the default data is returned.
- * When the field is submitted, the normalized submitted data is
+ * @return mixed When the field is not bound, the default data is returned.
+ * When the field is bound, the normalized bound data is
* returned if the field is valid, null otherwise.
*/
public function getNormalizedData()
@@ -355,17 +355,17 @@ public function addError(Error $error, PropertyPathIterator $pathIterator = null
}
/**
- * Returns whether the field is submitted.
+ * Returns whether the field is bound.
*
- * @return Boolean true if the form is submitted to input values, false otherwise
+ * @return Boolean true if the form is bound to input values, false otherwise
*/
- public function isSubmitted()
+ public function isBound()
{
- return $this->submitted;
+ return $this->bound;
}
/**
- * Returns whether the submitted value could be reverse transformed correctly
+ * Returns whether the bound value could be reverse transformed correctly
*
* @return Boolean
*/
@@ -381,13 +381,13 @@ public function isTransformationSuccessful()
*/
public function isValid()
{
- return $this->isSubmitted() && !$this->hasErrors(); // TESTME
+ return $this->isBound() && !$this->hasErrors(); // TESTME
}
/**
* Returns whether or not there are errors.
*
- * @return Boolean true if form is submitted and not valid
+ * @return Boolean true if form is bound and not valid
*/
public function hasErrors()
{
@@ -401,7 +401,7 @@ public function hasErrors()
/**
* Returns all errors
*
- * @return array An array of FieldError instances that occurred during submitting
+ * @return array An array of FieldError instances that occurred during binding
*/
public function getErrors()
{
View
4 FieldInterface.php
@@ -152,7 +152,7 @@ function isDisabled();
function isEmpty();
/**
- * Sets whether this field is required to be filled out when submitted.
+ * Sets whether this field is required to be filled out when bound.
*
* @param Boolean $required
*/
@@ -163,5 +163,5 @@ function setRequired($required);
*
* @param mixed $data The data from the POST request
*/
- function submit($data);
+ function bind($data);
}
View
26 Form.php
@@ -18,7 +18,7 @@
use Symfony\Component\Form\Event\FilterDataEvent;
use Symfony\Component\Form\Exception\FormException;
use Symfony\Component\Form\Exception\MissingOptionsException;
-use Symfony\Component\Form\Exception\AlreadySubmittedException;
+use Symfony\Component\Form\Exception\AlreadyBoundException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Exception\DanglingFieldException;
use Symfony\Component\Form\Exception\FieldDefinitionException;
@@ -50,7 +50,7 @@ class Form extends Field implements \IteratorAggregate, FormInterface, EventSubs
private $fields = array();
/**
- * Contains the names of submitted values who don't belong to any fields
+ * Contains the names of bound values who don't belong to any fields
* @var array
*/
private $extraFields = array();
@@ -131,8 +131,8 @@ public function __construct($name, EventDispatcherInterface $dispatcher,
*/
public function add($field)
{
- if ($this->isSubmitted()) {
- throw new AlreadySubmittedException('You cannot add fields after submitting a form');
+ if ($this->isBound()) {
+ throw new AlreadyBoundException('You cannot add fields after binding a form');
}
// if the field is given as string, ask the field factory of the form
@@ -295,7 +295,7 @@ public function filterBoundDataFromClient(FilterDataEvent $event)
foreach ($data as $name => $value) {
if ($this->has($name)) {
- $this->fields[$name]->submit($value);
+ $this->fields[$name]->bind($value);
}
}
@@ -319,10 +319,10 @@ public static function getSubscribedEvents()
*
* @param string|array $data The POST data
*/
- public function submit($data)
+ public function bind($data)
{
// set and reverse transform the data
- parent::submit($data);
+ parent::bind($data);
$this->extraFields = array();
@@ -388,11 +388,11 @@ public function isVirtual()
}
/**
- * Returns whether this form was submitted with extra fields
+ * Returns whether this form was bound with extra fields
*
* @return Boolean
*/
- public function isSubmittedWithExtraFields()
+ public function isBoundWithExtraFields()
{
// TODO: integrate the field names in the error message
return count($this->extraFields) > 0;
@@ -637,7 +637,7 @@ public function isCsrfTokenValid()
/**
* Binds a request to the form
*
- * If the request was a POST request, the data is submitted to the form,
+ * If the request was a POST request, the data is bound to the form,
* transformed and written into the form data (an object or an array).
* You can set the form data by passing it in the second parameter
* of this method or by passing it in the "data" option of the form's
@@ -645,11 +645,11 @@ public function isCsrfTokenValid()
*
* @param Request $request The request to bind to the form
* @param array|object $data The data from which to read default values
- * and where to write submitted values
+ * and where to write bound values
*/
public function bindRequest(Request $request)
{
- // Store the submitted data in case of a post request
+ // Store the bound data in case of a post request
switch ($request->getMethod()) {
case 'POST':
case 'PUT':
@@ -665,7 +665,7 @@ public function bindRequest(Request $request)
throw new FormException(sprintf('The request method "%s" is not supported', $request->getMethod()));
}
- $this->submit($data);
+ $this->bind($data);
$this->validate();
}
View
2  Renderer/Plugin/PasswordValuePlugin.php
@@ -25,7 +25,7 @@ public function __construct($alwaysEmpty = true)
public function setUp(FieldInterface $field, RendererInterface $renderer)
{
- $value = $this->alwaysEmpty || !$field->isSubmitted()
+ $value = $this->alwaysEmpty || !$field->isBound()
? ''
: $field->getTransformedData();
View
2  Resources/config/validation.xml
@@ -17,7 +17,7 @@
<property name="fields">
<constraint name="Valid" />
</property>
- <getter property="submittedWithExtraFields">
+ <getter property="boundWithExtraFields">
<constraint name="AssertFalse">
<option name="message">This form should not contain extra fields</option>
</constraint>
View
6 ValueTransformer/ValueTransformerInterface.php
@@ -24,8 +24,8 @@
* This method is called on two occasions inside a form field:
*
* 1. When the form field is initialized with the data attached from the datasource (object or array).
- * 2. When data from a request is bound using {@link Field::submit()} to transform the new input data
- * back into the renderable format. For example if you have a date field and submit '2009-10-10' onto
+ * 2. When data from a request is bound using {@link Field::bind()} to transform the new input data
+ * back into the renderable format. For example if you have a date field and bind '2009-10-10' onto
* it you might accept this value because its easily parsed, but the transformer still writes back
* "2009/10/10" onto the form field (for further displaying or other purposes).
*
@@ -50,7 +50,7 @@ function transform($value);
* Transforms a value from the transformed representation to its original
* representation.
*
- * This method is called when {@link Field::submit()} is called to transform the requests tainted data
+ * This method is called when {@link Field::bind()} is called to transform the requests tainted data
* into an acceptable format for your data processing/model layer.
*
* This method must be able to deal with empty values. Usually this will
Please sign in to comment.
Something went wrong with that request. Please try again.