|
94 | 94 | ```
|
95 | 95 | * The custom factories for the firewall configuration are now
|
96 | 96 | registered during the build method of bundles instead of being registered
|
97 |
| - by the end-user. This means that you will you need to remove the 'factories' |
| 97 | + by the end-user. This means that you will you need to remove the 'factories' |
98 | 98 | keys in your security configuration.
|
99 | 99 |
|
100 | 100 | * The Firewall listener is now registered after the Router listener. This
|
|
372 | 372 | return isset($options['widget']) && 'single_text' === $options['widget'] ? 'text' : 'choice';
|
373 | 373 | }
|
374 | 374 | ```
|
375 |
| - |
| 375 | +
|
376 | 376 | * The methods `getDefaultOptions()` and `getAllowedOptionValues()` of form
|
377 | 377 | types no longer receive an option array.
|
378 |
| - |
| 378 | +
|
379 | 379 | You can specify options that depend on other options using closures instead.
|
380 |
| - |
| 380 | +
|
381 | 381 | Before:
|
382 |
| - |
| 382 | +
|
383 | 383 | ```
|
384 | 384 | public function getDefaultOptions(array $options)
|
385 | 385 | {
|
386 | 386 | $defaultOptions = array();
|
387 |
| - |
| 387 | +
|
388 | 388 | if ($options['multiple']) {
|
389 | 389 | $defaultOptions['empty_data'] = array();
|
390 | 390 | }
|
391 |
| - |
| 391 | +
|
392 | 392 | return $defaultOptions;
|
393 | 393 | }
|
394 | 394 | ```
|
395 |
| - |
| 395 | +
|
396 | 396 | After:
|
397 |
| - |
| 397 | +
|
398 | 398 | ```
|
399 | 399 | public function getDefaultOptions()
|
400 | 400 | {
|
|
405 | 405 | );
|
406 | 406 | }
|
407 | 407 | ```
|
408 |
| - |
| 408 | +
|
409 | 409 | The second argument `$previousValue` does not have to be specified if not
|
410 | 410 | needed.
|
411 | 411 |
|
|
425 | 425 | (or any other of the BIND events). In case you used the CallbackValidator
|
426 | 426 | class, you should now pass the callback directly to `addEventListener`.
|
427 | 427 |
|
| 428 | + * FieldType was merged into FormType. FieldType itself was deprecated and |
| 429 | + will be removed in Symfony 2.3. |
| 430 | +
|
| 431 | + ##### Update your field types |
| 432 | +
|
| 433 | + You are advised to update your custom types that extend FieldType to extend |
| 434 | + FormType instead. |
| 435 | +
|
| 436 | + Before: |
| 437 | +
|
| 438 | + ``` |
| 439 | + public function getParent(array $options) |
| 440 | + { |
| 441 | + return 'field'; |
| 442 | + } |
| 443 | + ``` |
| 444 | +
|
| 445 | + After: |
| 446 | +
|
| 447 | + ``` |
| 448 | + public function getParent(array $options) |
| 449 | + { |
| 450 | + return 'form'; |
| 451 | + } |
| 452 | + ``` |
| 453 | +
|
| 454 | + You can also remove the getParent() method as this is the default |
| 455 | + implementation in AbstractType. |
| 456 | +
|
| 457 | + ##### Update your form themes |
| 458 | +
|
| 459 | + Previously, FieldType was the super type for all other types. Now, since |
| 460 | + it is deprecated, FieldType is a subtype of FormType, which is now the base |
| 461 | + type for all other types. |
| 462 | +
|
| 463 | + A consequence of this change is that any "form_*" blocks defined in your |
| 464 | + themes are now also used for other types that extend "field", unless you |
| 465 | + explicitely override the "field_*" or "mytype_*" blocks. |
| 466 | +
|
| 467 | + "field_*" blocks are deprecated and will be unsupported as of Symfony 2.3. |
| 468 | + You should merge them into the corresponding "form_*" blocks instead. |
| 469 | +
|
| 470 | + Before: |
| 471 | +
|
| 472 | + ``` |
| 473 | + {% block field_label %} |
| 474 | + {% spaceless %} |
| 475 | + {% set attr = attr|merge({'for': id}) %} |
| 476 | + {{ block('generic_label') }} |
| 477 | + {% endspaceless %} |
| 478 | + {% endblock field_label %} |
| 479 | +
|
| 480 | + {% block form_label %} |
| 481 | + {% spaceless %} |
| 482 | + {{ block('generic_label') }} |
| 483 | + {% endspaceless %} |
| 484 | + {% endblock form_label %} |
| 485 | + ``` |
| 486 | +
|
| 487 | + After: |
| 488 | +
|
| 489 | + ``` |
| 490 | + {% block form_label %} |
| 491 | + {% spaceless %} |
| 492 | + {% if form.children|length == 0 %} |
| 493 | + {% set attr = attr|merge({'for': id}) %} |
| 494 | + {% endif %} |
| 495 | + {{ block('generic_label') }} |
| 496 | + {% endspaceless %} |
| 497 | + {% endblock form_label %} |
| 498 | + ``` |
| 499 | +
|
| 500 | + The block "field_widget" was renamed to "input" and is still supported. |
| 501 | +
|
| 502 | + Before: |
| 503 | +
|
| 504 | + ``` |
| 505 | + {% block field_widget %} |
| 506 | + {% spaceless %} |
| 507 | + <!-- custom input tag --> |
| 508 | + {% endspaceless %} |
| 509 | + {% endblock field_widget %} |
| 510 | + ``` |
| 511 | +
|
| 512 | + After: |
| 513 | +
|
| 514 | + ``` |
| 515 | + {% block input %} |
| 516 | + {% spaceless %} |
| 517 | + <!-- custom input tag --> |
| 518 | + {% endspaceless %} |
| 519 | + {% endblock input %} |
| 520 | + ``` |
| 521 | +
|
428 | 522 | ### Session
|
429 | 523 |
|
430 | 524 | * Flash messages now return an array based on their type. The old method is
|
|
0 commit comments