8000 [Form] Fixed results of the FieldType+FormType merge. · symfony/symfony@eb75ab1 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb75ab1

Browse files
committed
[Form] Fixed results of the FieldType+FormType merge.
1 parent a01dec0 commit eb75ab1

File tree

59 files changed

+396
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+396
-273
lines changed

UPGRADE-2.1.md

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
```
103103
* The custom factories for the firewall configuration are now
104104
registered during the build method of bundles instead of being registered
105-
by the end-user. This means that you will you need to remove the 'factories'
105+
by the end-user. This means that you will you need to remove the 'factories'
106106
keys in your security configuration.
107107
108108
* The Firewall listener is now registered after the Router listener. This
@@ -313,29 +313,29 @@
313313
return isset($options['widget']) && 'single_text' === $options['widget'] ? 'text' : 'choice';
314314
}
315315
```
316-
316+
317317
* The methods `getDefaultOptions()` and `getAllowedOptionValues()` of form
318318
types no longer receive an option array.
319-
319+
320320
You can specify options that depend on other options using closures instead.
321-
321+
322322
Before:
323-
323+
324324
```
325325
public function getDefaultOptions(array $options)
326326
{
327327
$defaultOptions = array();
328-
328+
329329
if ($options['multiple']) {
330330
$defaultOptions['empty_data'] = array();
331331
}
332-
332+
333333
return $defaultOptions;
334334
}
335335
```
336-
336+
337337
After:
338-
338+
339339
```
340340
public function getDefaultOptions()
341341
{
@@ -346,7 +346,7 @@
346346
);
347347
}
348348
```
349-
349+
350350
The second argument `$previousValue` does not have to be specified if not
351351
needed.
352352
@@ -366,29 +366,92 @@
366366
(or any other of the BIND events). In case you used the CallbackValidator
367367
class, you should now pass the callback directly to `addEventListener`.
368368
369-
* simplified CSRF protection and removed the csrf type
369+
* Since FormType and FieldType were merged, you need to adapt your form
370+
themes.
371+
372+
The "field_widget" and all references to it should be renamed to
373+
"form_widget_primitive":
374+
375+
Before:
376+
377+
```
378+
{% block url_widget %}
379+
{% spaceless %}
380+
{% set type = type|default('url') %}
381+
{{ block('field_widget') }}
382+
{% endspaceless %}
383+
{% endblock url_widget %}
384+
```
385+
386+
After:
387+
388+
```
389+
{% block url_widget %}
390+
{% spaceless %}
391+
{% set type = type|default('url') %}
392+
{{ block('form_widget_primitive') }}
393+
{% endspaceless %}
394+
{% endblock url_widget %}
395+
```
396+
397+
All other "field_*" blocks and references to them should be renamed to
398+
"form_*". If you previously defined both a "field_*" and a "form_*"
399+
block, you can merge them into a single "form_*" block and check the new
400+
Boolean variable "primitive":
401+
402+
Before:
403+
404+
```
405+
{% block form_errors %}
406+
{% spaceless %}
407+
... form code ...
408+
{% endspaceless %}
409+
{% endblock form_errors %}
370410
371-
* deprecated FieldType and merged it into FormType
411+
{% block field_errors %}
412+
{% spaceless %}
413+
... field code ...
414+
{% endspaceless %}
415+
{% endblock field_errors %}
416+
```
417+
418+
After:
419+
420+
```
421+
{% block form_errors %}
422+
{% spaceless %}
423+
{% if primitive %}
424+
... field code ...
425+
{% else %}
426+
... form code ...
427+
{% endif %}
428+
{% endspaceless %}
429+
{% endblock form_errors %}
430+
```
431+
432+
Furthermore, the block "generic_label" was merged into "form_label". You
433+
should now override "form_label" in order to customize labels.
434+
435+
Last but not least, the block "widget_choice_options" was renamed to
436+
"choice_widget_options" to be consistent with the rest of the default
437+
theme.
372438
373-
* [BC BREAK] renamed "field_*" theme blocks to "form_*" and "field_widget" to
374-
"input"
375-
376439
* The method `guessMinLength()` of FormTypeGuesserInterface was deprecated
377440
and will be removed in Symfony 2.3. You should use the new method
378441
`guessPattern()` instead which may return any regular expression that
379442
is inserted in the HTML5 attribute "pattern".
380-
443+
381444
Before:
382-
445+
383446
public function guessMinLength($class, $property)
384447
{
385448
if (/* condition */) {
386449
return new ValueGuess($minLength, Guess::LOW_CONFIDENCE);
387450
}
388451
}
389-
452+
390453
After:
391-
454+
392455
public function guessPattern($class, $property)
393456
{
394457
if (/* condition */) {
@@ -470,7 +533,7 @@
470533
`validate` and its return value was dropped.
471534
472535
`ConstraintValidator` still contains the deprecated `isValid` method and
473-
forwards `validate` calls to `isValid` by default. This BC layer will be
536+
forwards `validate` calls to `isValid` by default. This BC layer will be
474537
removed in Symfony 2.3. You are advised to rename your methods. You should
475538
also remove the return values, which have never been used by the framework.
476539
@@ -500,7 +563,7 @@
500563
$this->context->addViolation($constraint->message, array(
501564
'{{ value }}' => $value,
502565
));
503-
566+
504567
return;
505568
}
506569
}

0 commit comments

Comments
 (0)
0