Skip to content

[Form][2.8] performing a data transformation on a form element doesn't propagate further #18683

@er1z

Description

@er1z

I'm struggling with a following issue: I'm working with a DataTransformer and form based on array as a form model.

Form works well, of course. And I add a view transformer

$builder->get('field')->addViewTransformer(new MyTransformer());

If I submit a form, transformer works well:

$form->get('field')->getViewData();

And I get the transformed data correctly. But if I want to gather view data for whole form:

$form->getViewData();

It's synchronized with normalized data - transformed result is completely discarded. The, done some digging and found out that this code is enforcing data overwriting: https://github.com/symfony/form/blob/2.8/Form.php#L616

I'm using a stock mapper, PropertyPathMapper.

Am I using something wrong or is this a bug? I'd like to get a view data for whole form, binding data transformer to a particular field. Right now, the only solution is to bind this to very whole builder.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions