Add ViewTransformer to SonataAdmin

Symfony2

Some time I can't find how to add data transformer to SonataAdmin field. After some investigating I find answer. In configureFormFields method we have FormMapper instance from what we need to get FormBuilder. Add DataTransformer to FormBilder is simple:

$formMapper->getFormBuilder()->get('field')->addViewTransformer(new FieldTransformer());

Comments

Login with GitHub to leave a comments