nbro
nbro

Reputation: 15857

Access form's submitted data after (data) transformations have been applied?

I need to access in the controller the form's submitted data/fields after all (data transformations) have been applied.

I need to do it because I need to access a transformed data, but using for example $request->request->get('product')['tags']), I get the original submitted data, which is a string instead of an array of Tag objects (which is what in my case the data transformer does, i.e. converts a comma separate string of names to an array of Tag objects), which is what I need to access in the controller.

Upvotes: 1

Views: 29

Answers (1)

vinzao
vinzao

Reputation: 11

Through the Symfony\Component\HttpFoundation\Request Object, you can only get the raw submitted data which is a string of tag names separated by commas in your case.

The Data Transformer of the Form component act on the actual object which in your case is Product, so you have to access the Tag objects via the Product object instead.

$tags = $product->getTags(); // Collection of Tag objects

Upvotes: 1

Related Questions