Skip to content

[Form] Inserted a warning about a limitation of model transformers #15780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions form/data_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,21 @@ Which transformer you need depends on your situation.

To use the view transformer, call ``addViewTransformer()``.

.. caution::

Be careful with model transformers and
:doc:`Collection </reference/forms/types/collection>` field types: As the
Collection's children are created early at `PRE_SET_DATA` by its
`ResizeFormListener`, their data is populated later from the Norm Data. So
your model transformer cannot reduce the number of items within the
Collection (i.e. filtering out some items), as in that case the collection
ends up with some empty children.

A possible workaround for that limitation could be not using the underlying
object directly, but a DTO (Data Transfer Object) instead, that implements
the transformation of such incompatible data structures.


So why Use the Model Transformer?
---------------------------------

Expand Down