Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] entry_type with FQCN and empty_data issue within collection #19165

Copy link
Copy link
Closed
@DonCallisto

Description

@DonCallisto
Issue body actions

Running on an application with SF2.8, before migrating it to SF3. What I got here is, at some point in a form

    // BarType.php
    $builder->add('foo', CollectionType::class, [
       'entry_type'     => new FooType(),
       'error_bubbling' => false,
       'allow_add'      => true,
       'allow_delete'   => true,
    ]);

Reading this I found that we need to change entry_type of forms from new FooType() to FooType::class.

But I've noticed something very weird: if I change entry_type from instance to FQCN and in embedded form (FooType) I use something like

    // FooType.php
    $resolver->setDefaults([
        'data_class' => 'Vendor\Bundle\Entity\Foo',
        'empty_data' => new Foo(),
    ]);

Then, every object added to the collection are "collapsed" into the same one (e.g.: I add three elements, after form binding I got three Foo elements in my Bar object but they're all the same).

Unfortunately, now, I cannot write an example to let give you a better understand of what is going on here but I will do in the next days if anyone need it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.