From c09bad8aead032da5154135e8f4c8008e3e6ff7f Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 6 Jul 2012 17:59:44 +0200 Subject: [PATCH] [Form] Clarified how to adapt forms that inherited from FieldType for Symfony 2.1 --- UPGRADE-2.1.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/UPGRADE-2.1.md b/UPGRADE-2.1.md index a1077fd794..76f710215d 100644 --- a/UPGRADE-2.1.md +++ b/UPGRADE-2.1.md @@ -239,6 +239,40 @@ public function finishView(FormViewInterface $view, FormInterface $form, array $options) ``` + * If you previously inherited from `FieldType`, you should now inherit from + `FormType`. You should also set the option `compound` to `false` if your field + is not supposed to contain child fields. + + `FieldType` was deprecated and will be removed in Symfony 2.3. + + Before: + + ``` + public function getParent(array $options) + { + return 'field'; + } + ``` + + After: + + ``` + public function getParent() + { + return 'form'; + } + + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'compound' => false, + )); + } + ``` + + The changed signature of `getParent()` is explained in the next step. + The new method `setDefaultOptions` is described in the section "Deprecations". + * No options are passed to `getParent()` of `FormTypeInterface` anymore. If you previously dynamically inherited from `FormType` or `FieldType`, you can now dynamically set the "compound" option instead.