Skip to content

[Form] Collection FormType with a all fields disabled is deleted at submit #18998

Closed
@steevanb

Description

@steevanb

If i have this FormType, for EntityA :

class FormTypeA extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('my_collection', CollectionType::class, [
            'entry_type' => FormTypeB::class
        ]);
    }
}

And this one, for EntityB :

class FormTypeB extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('field', TextAreaType::class, [
            'disabled' => true
        ]);
    }
}

When i submit my form, "all" EntityB are removed from my database => that's not what i expect, i just want to not save any modification on "field".

If i add another field into FormTypeB, "who is not disabled", nothing is removed, disabled does it's job (don't save any modification into this disabled field), that's fine.

If i add another field into FormTypeB, "who is disabled", same problem : when i submit my form, "all" EntityB are removed from my database => that's not what i expect

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