Skip to content

Commit 0762848

Browse files
committed
Adding an example of how the other format for attaching transformers looks
1 parent 28d7f89 commit 0762848

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cookbook/form/data_transformers.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ in your code.
100100
:class:`Symfony\\Component\\Form\\DataTransformerInterface` - so you can create
101101
your own classes, instead of putting all the logic in the form (see the next section).
102102

103+
You can also add the transformer, right when adding the field by changing the format
104+
slightly::
105+
106+
$builder->add(
107+
$builder->create('description', 'textarea')
108+
->addModelTransformer(...)
109+
);
110+
103111
Harder Example: Transforming an Issue Number into an Issue Entity
104112
-----------------------------------------------------------------
105113

0 commit comments

Comments
 (0)