Skip to content

Commit 9cfc826

Browse files
committed
minor #12468 [Form] Removed sidebar about Stateful data mappers (wouterj)
This PR was merged into the 3.4 branch. Discussion ---------- [Form] Removed sidebar about Stateful data mappers Fixes #11401 As you can see in the referenced comment by @webmozart, having to implement the data mapper in a separate class is a real edge-case: It would have to depend on an option configured on the Form. I would say it's better to just completely remove the sidebar. If a user needs such advanced usage of the form component, they'll probably find out themselves that you can also pass instances of another class to this method. Commits ------- 60b7dd8 Removed sidebar about Statefull data mappers
2 parents 723ab0a + 60b7dd8 commit 9cfc826

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

form/data_mappers.rst

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,30 +192,3 @@ create a new ``Color`` object now.
192192

193193
When a form has the ``inherit_data`` option set to ``true``, it does not use the data mapper and
194194
lets its parent map inner values.
195-
196-
.. sidebar:: Stateful Data Mappers
197-
198-
Sometimes, data mappers need to access services or need to maintain their
199-
state. In this case, you cannot implement the methods in the form type
200-
itself. Create a separate class implementing ``DataMapperInterface`` and
201-
initialize it in your form type::
202-
203-
// src/AppBundle/Form/Type/ColorType.php
204-
205-
// ...
206-
use AppBundle\Form\DataMapper\ColorMapper;
207-
208-
final class ColorType extends AbstractType
209-
{
210-
public function buildForm(FormBuilderInterface $builder, array $options)
211-
{
212-
$builder
213-
// ...
214-
215-
// Initialize the data mapper class and e.g. pass some state
216-
->setDataMapper(new ColorMapper($options['opacity']))
217-
;
218-
}
219-
220-
// ...
221-
}

0 commit comments

Comments
 (0)