Skip to content

How to work with Model Transformers? #17

Closed
@Gerben321

Description

@Gerben321

Thanks for this awesome package. It was a bit of messing around but I managed to get an existing form working with some dynamic fields.

However, I am facing a little problem. I've got an issue with model transformers. All of my dynamic fields have them. The reason is because my data in the database is stored differently from how it's shown to the user. So there's a transform action for getting and setting it from/to the database.

I can't figure out how to get these working. In my old situation I used to run this code:

$builder
  ->get('field')
  ->addModelTransformer(new CallbackTransformer(...etc

This is no longer working with the dynamic form fields. The error was somewhat expectable: 'The child with the name "field" does not exist.'. So, I wrapped the function in this:

if ($builder->has('field')) {

Sadly, this always returns false even though the field is rendered. How can I make this work again? I hope I don't have to work with the somewhat ugly Form Events.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions