Skip to content

Commit b654800

Browse files
committed
Removed notion "bind" from the documentation
1 parent 48e7ded commit b654800

File tree

10 files changed

+62
-46
lines changed

10 files changed

+62
-46
lines changed

book/forms.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ controller::
226226
.. versionadded:: 2.3
227227
The :method:`Symfony\Component\Form\FormInterface::handleRequest` method was
228228
added in Symfony 2.3. Previously, the ``$request`` was passed to the
229-
``bind`` method - a strategy which is deprecated and will be removed
230-
in Symfony 3.0. For details on that method, see :doc:`/cookbook/form/direct_bind`.
229+
``submit`` method - a strategy which is deprecated and will be removed
230+
in Symfony 3.0. For details on that method, see :doc:`/cookbook/form/direct_submit`.
231231

232232
This controller follows a common pattern for handling forms, and has three
233233
possible paths:
@@ -247,7 +247,7 @@ possible paths:
247247

248248
.. note::
249249

250-
You can use the method :method:`Symfony\Component\Form\FormInterface::isBound`
250+
You can use the method :method:`Symfony\Component\Form\FormInterface::isSubmitted`
251251
to check whether a form was submitted, regardless of whether or not the
252252
submitted data is actually valid.
253253

book/validation.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ Validation and Forms
205205
The ``validator`` service can be used at any time to validate any object.
206206
In reality, however, you'll usually work with the ``validator`` indirectly
207207
when working with forms. Symfony's form library uses the ``validator`` service
208-
internally to validate the underlying object after values have been submitted
209-
and bound. The constraint violations on the object are converted into ``FieldError``
208+
internally to validate the underlying object after values have been submitted.
209+
The constraint violations on the object are converted into ``FieldError``
210210
objects that can easily be displayed with your form. The typical form submission
211211
workflow looks like the following from inside a controller::
212212

cookbook/form/data_transformers.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ when creating your form. Later, you'll learn how you could create a custom
157157

158158
Cool, you're done! Your user will be able to enter an issue number into the
159159
text field and it will be transformed back into an Issue object. This means
160-
that, after a successful bind, the Form framework will pass a real Issue
160+
that, after a successful submission, the Form framework will pass a real Issue
161161
object to ``Task::setIssue()`` instead of the issue number.
162162

163163
If the issue isn't found, a form error will be created for that field and
@@ -201,7 +201,7 @@ used directly.
201201

202202
3) **View Data** - This is the format that's used to fill in the form fields
203203
themselves. It's also the format in which the user will submit the data. When
204-
you call ``Form::bind($data)``, the ``$data`` is in the "view" data format.
204+
you call ``Form::submit($data)``, the ``$data`` is in the "view" data format.
205205

206206
The 2 different types of transformers help convert to and from each of these
207207
types of data:

cookbook/form/direct_bind.rst renamed to cookbook/form/direct_submit.rst

+30-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. index::
2-
single: Form; Form::bind
2+
single: Form; Form::submit()
33

4-
How to use the bind Function to handle Form Submissions
5-
=======================================================
4+
How to use the submit() Function to handle Form Submissions
5+
===========================================================
66

77
In Symfony 2.3, a new :method:`Symfony\Component\Form\FormInterface::handleRequest`
88
method was added, which makes handling form submissions easier than ever::
@@ -33,11 +33,14 @@ method was added, which makes handling form submissions easier than ever::
3333

3434
To see more about this method, read :ref:`book-form-handling-form-submissions`.
3535

36-
Using Form::bind() to handle a request (deprecated)
37-
---------------------------------------------------
36+
Calling Form::submit() manually
37+
-------------------------------
3838

39-
Prior to this, the :method:`Symfony\Component\Form\FormInterface::bind` method
40-
was used instead::
39+
In some cases, you want better control over when exactly your form is submitted
40+
and what data is passed to it. Instead of using the
41+
:method:`Symfony\Component\Form\FormInterface::handleRequest`
42+
method, pass the submitted data directly to
43+
:method:`Symfony\Component\Form\FormInterface::submit`::
4144

4245
use Symfony\Component\HttpFoundation\Request;
4346
// ...
@@ -49,7 +52,7 @@ was used instead::
4952
->getForm();
5053

5154
if ($request->isMethod('POST')) {
52-
$form->bind($request);
55+
$form->submit($request->request->get($form->getName()));
5356

5457
if ($form->isValid()) {
5558
// perform some action...
@@ -63,17 +66,21 @@ was used instead::
6366
));
6467
}
6568

66-
Passing the :class:`Symfony\\Component\HttpFoundation\\Request` directly to
67-
``bind`` still works, but is deprecated and will be removed in Symfony 3.0.
68-
However, you *can* safely pass array values directly to bind.
69+
.. tip::
70+
71+
Forms consisting of nested fields expect an array in
72+
:method:`Symfony\Component\Form\FormInterface::submit`. You can also submit
73+
individual fields by calling :method:`Symfony\Component\Form\FormInterface::submit`
74+
directly on the field::
6975

70-
Passing an Array directly to Form::bind
71-
---------------------------------------
76+
$form->get('firstName')->submit('Fabien');
7277

73-
In some cases, you may want to collect and pass an array of values directly
74-
to a Form, instead of using the ``handleRequest`` method. This is absolutely
75-
valid and not deprecated (passing a :class:`Symfony\\Component\HttpFoundation\\Request`
76-
object to ``Form::bind`` is deprecated, but passing an array of ok)::
78+
Passing a Request to Form::submit() (deprecated)
79+
------------------------------------------------
80+
81+
Before Symfony 2.3, the :method:`Symfony\Component\Form\FormInterface::submit`
82+
method accepted a :class:`Symfony\\Component\\HttpFoundation\\Reuqest` object as
83+
a convenient shortcut to the previous example::
7784

7885
use Symfony\Component\HttpFoundation\Request;
7986
// ...
@@ -85,7 +92,7 @@ object to ``Form::bind`` is deprecated, but passing an array of ok)::
8592
->getForm();
8693

8794
if ($request->isMethod('POST')) {
88-
$form->bind($request->request->get($form->getName()));
95+
$form->submit($request);
8996

9097
if ($form->isValid()) {
9198
// perform some action...
@@ -98,3 +105,8 @@ object to ``Form::bind`` is deprecated, but passing an array of ok)::
98105
'form' => $form->createView(),
99106
));
100107
}
108+
109+
Passing the :class:`Symfony\\Component\HttpFoundation\\Request` directly to
110+
:method:`Symfony\\Component\\Form\\FormInterface::submit`` still works, but is
111+
deprecated and will be removed in Symfony 3.0. You should use the method
112+
:method:`Symfony\Component\Form\FormInterface::handleRequest` instead.

cookbook/form/dynamic_form_modification.rst

+15-11
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,18 @@ On a form, we can usually listen to the following events:
444444

445445
* ``PRE_SET_DATA``
446446
* ``POST_SET_DATA``
447-
* ``PRE_BIND``
448-
* ``BIND``
449-
* ``POST_BIND``
447+
* ``PRE_SUBMIT``
448+
* ``SUBMIT``
449+
* ``POST_SUBMIT``
450450

451-
When listening to ``BIND`` and ``POST_BIND``, it's already "too late" to make
452-
changes to the form. Fortunately, ``PRE_BIND`` is perfect for this. There
451+
.. versionadded:: 2.3
452+
The events ``PRE_SUBMIT``, ``SUBMIT`` and ``POST_SUBMIT`` were added in
453+
Symfony 2.3. Before, they were named ``PRE_BIND``, ``BIND`` and ``POST_BIND``.
454+
455+
When listening to ``SUBMIT`` and ``POST_SUBMIT``, it's already "too late" to make
456+
changes to the form. Fortunately, ``PRE_SUBMIT`` is perfect for this. There
453457
is, however, a big difference in what ``$event->getData()`` returns for each
454-
of these events. Specifically, in ``PRE_BIND``, ``$event->getData()`` returns
458+
of these events. Specifically, in ``PRE_SUBMIT``, ``$event->getData()`` returns
455459
the raw data submitted by the user.
456460

457461
This can be used to get the ``SportMeetup`` id and retrieve it from the database,
@@ -494,7 +498,7 @@ The subscriber would now look like::
494498
public static function getSubscribedEvents()
495499
{
496500
return array(
497-
FormEvents::PRE_BIND => 'preBind',
501+
FormEvents::PRE_SUBMIT => 'preSubmit',
498502
FormEvents::PRE_SET_DATA => 'preSetData',
499503
);
500504
}
@@ -506,7 +510,7 @@ The subscriber would now look like::
506510
{
507511
$meetup = $event->getData()->getMeetup();
508512

509-
// Before binding the form, the "meetup" will be null
513+
// Before SUBMITing the form, the "meetup" will be null
510514
if (null === $meetup) {
511515
return;
512516
}
@@ -517,7 +521,7 @@ The subscriber would now look like::
517521
$this->customizeForm($form, $positions);
518522
}
519523

520-
public function preBind(FormEvent $event)
524+
public function preSubmit(FormEvent $event)
521525
{
522526
$data = $event->getData();
523527
$id = $data['event'];
@@ -617,6 +621,6 @@ set for every possible kind of sport that our users are registering for.
617621

618622
One piece that may still be missing is the client-side updating of your form
619623
after the sport is selected. This should be handled by making an AJAX call
620-
back to your application. In that controller, you can bind your form, but
621-
instead of processing it, simply use the bound form to render the updated
624+
back to your application. In that controller, you can submit your form, but
625+
instead of processing it, simply use the submitted form to render the updated
622626
fields. The response from the AJAX call can then be used to update the view.

cookbook/form/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ Form
1313
use_virtuals_forms
1414
unit_testing
1515
use_empty_data
16-
direct_bind
16+
direct_submit

cookbook/form/unit_testing.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The simplest ``TypeTestCase`` implementation looks like the following::
4040

4141
class TestedTypeTest extends TypeTestCase
4242
{
43-
public function testBindValidData()
43+
public function testSubmitValidData()
4444
{
4545
$formData = array(
4646
'test' => 'test',
@@ -53,8 +53,8 @@ The simplest ``TypeTestCase`` implementation looks like the following::
5353
$object = new TestObject();
5454
$object->fromArray($formData);
5555

56-
// bind the data to the form directly
57-
$form->bind($formData);
56+
// submit the data to the form directly
57+
$form->submit($formData);
5858

5959
$this->assertTrue($form->isSynchronized());
6060
$this->assertEquals($object, $form->getData());
@@ -81,7 +81,7 @@ This test checks that none of your data transformers used by the form
8181
failed. The :method:`Symfony\\Component\\Form\\FormInterface::isSynchronized``
8282
method is only set to ``false`` if a data transformer throws an exception::
8383

84-
$form->bind($formData);
84+
$form->submit($formData);
8585
$this->assertTrue($form->isSynchronized());
8686

8787
.. note::
@@ -90,7 +90,7 @@ method is only set to ``false`` if a data transformer throws an exception::
9090
active in the test case and it relies on validation configuration.
9191
Instead, unit test your custom constraints directly.
9292

93-
Next, verify the binding and mapping of the form. The test below
93+
Next, verify the submission and mapping of the form. The test below
9494
checks if all the fields are correctly specified::
9595

9696
$this->assertEquals($object, $form->getData());
@@ -129,7 +129,7 @@ before creating the parent form::
129129

130130
class TestedTypeTest extends TypeTestCase
131131
{
132-
public function testBindValidData()
132+
public function testSubmitValidData()
133133
{
134134
$this->factory->addType(new TestChildType());
135135

cookbook/form/use_empty_data.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ How to configure Empty Data for a Form Class
55
============================================
66

77
The ``empty_data`` option allows you to specify an empty data set for your
8-
form class. This empty data set would be used if you bind your form, but
8+
form class. This empty data set would be used if you submit your form, but
99
haven't called ``setData()`` on your form or passed in data when you created
1010
you form. For example::
1111

cookbook/security/acl.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Creating an ACL, and adding an ACE
102102
{
103103
$comment = new Comment();
104104
105-
// ... setup $form, and bind data
105+
// ... setup $form, and submit data
106106
107107
if ($form->isValid()) {
108108
$entityManager = $this->getDoctrine()->getManager();

reference/forms/types/url.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ default_protocol
3636

3737
If a value is submitted that doesn't begin with some protocol (e.g. ``http://``,
3838
``ftp://``, etc), this protocol will be prepended to the string when
39-
the data is bound to the form.
39+
the data is submitted to the form.
4040

4141
Inherited Options
4242
-----------------

0 commit comments

Comments
 (0)