Skip to content

Commit 68f360c

Browse files
committed
[Form] Moved upgrade nodes to UPGRADE-3.0
1 parent 01b71a4 commit 68f360c

File tree

2 files changed

+142
-1
lines changed

2 files changed

+142
-1
lines changed

UPGRADE-2.3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
UPGRADE FROM 2.2 to 2.3
1+
UPGRADE FROM 2.2 to 2.3
22
=======================
33

44
### Form

UPGRADE-3.0.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,97 @@ UPGRADE FROM 2.x to 3.0
1818
`DebugClassLoader`. The difference is that the constructor now takes a
1919
loader to wrap.
2020

21+
### Form
22+
23+
* Passing a `Symfony\Component\HttpFoundation\Request` instance to
24+
`FormInterface::bind()` was disabled. You should use
25+
`FormInterface::process()` instead.
26+
27+
Before:
28+
29+
```
30+
if ('POST' === $request->getMethod()) {
31+
$form->bind($request);
32+
33+
if ($form->isValid()) {
34+
// ...
35+
}
36+
}
37+
```
38+
39+
After:
40+
41+
```
42+
if ($form->process($request)->isValid()) {
43+
// ...
44+
}
45+
```
46+
47+
If you want to test whether the form was submitted separately, you can use
48+
the method `isBound()`:
49+
50+
```
51+
if ($form->process($request)->isBound()) {
52+
// ...
53+
54+
if ($form->isValid()) {
55+
// ...
56+
}
57+
}
58+
```
59+
60+
### FrameworkBundle
61+
62+
* The `enctype` method of the `form` helper was removed. You should use the
63+
new method `start` instead.
64+
65+
Before:
66+
67+
```
68+
<form method="post" action="http://example.com" <?php echo $view['form']->enctype($form) ?>>
69+
...
70+
</form>
71+
```
72+
73+
After:
74+
75+
```
76+
<?php echo $view['form']->start($form) ?>
77+
...
78+
<?php echo $view['form']->end($form) ?>
79+
```
80+
81+
The method and action of the form default to "POST" and the current
82+
document. If you want to change these values, you can set them explicitly in
83+
the controller.
84+
85+
Alternative 1:
86+
87+
```
88+
$form = $this->createForm('my_form', $formData, array(
89+
'method' => 'PUT',
90+
'action' => $this->generateUrl('target_route'),
91+
));
92+
```
93+
94+
Alternative 2:
95+
96+
```
97+
$form = $this->createFormBuilder($formData)
98+
// ...
99+
->setMethod('PUT')
100+
->setAction($this->generateUrl('target_route'))
101+
->getForm();
102+
```
103+
104+
It is also possible to override the method and the action in the template:
105+
106+
```
107+
<?php echo $view['form']->start($form, array('method' => 'GET', 'action' => 'http://example.com')) ?>
108+
...
109+
<?php echo $view['form']->end($form) ?>
110+
```
111+
21112
### HttpKernel
22113

23114
* The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in
@@ -98,6 +189,56 @@ UPGRADE FROM 2.x to 3.0
98189

99190
* The `render` tag is deprecated in favor of the `render` function.
100191

192+
* The `form_enctype` helper was removed. You should use the new `form_start`
193+
function instead.
194+
195+
Before:
196+
197+
```
198+
<form method="post" action="http://example.com" {{ form_enctype(form) }}>
199+
...
200+
</form>
201+
```
202+
203+
After:
204+
205+
```
206+
{{ form_start(form) }}
207+
...
208+
{{ form_end(form) }}
209+
```
210+
211+
The method and action of the form default to "POST" and the current
212+
document. If you want to change these values, you can set them explicitly in
213+
the controller.
214+
215+
Alternative 1:
216+
217+
```
218+
$form = $this->createForm('my_form', $formData, array(
219+
'method' => 'PUT',
220+
'action' => $this->generateUrl('target_route'),
221+
));
222+
```
223+
224+
Alternative 2:
225+
226+
```
227+
$form = $this->createFormBuilder($formData)
228+
// ...
229+
->setMethod('PUT')
230+
->setAction($this->generateUrl('target_route'))
231+
->getForm();
232+
```
233+
234+
It is also possible to override the method and the action in the template:
235+
236+
```
237+
{{ form_start(form, {'method': 'GET', 'action': 'http://example.com'}) }}
238+
...
239+
{{ form_end(form) }}
240+
```
241+
101242
### Yaml
102243

103244
* The ability to pass file names to `Yaml::parse()` has been removed.

0 commit comments

Comments
 (0)