I have a problem with sonata admin, specifically in a type collection field. Here's the scenario:
I have an entity called "Group" with a one to many relationship to the entity "Member"
In sonata admin I set up the admin classes for the 2 entities.
In the "Group admin" i create a collection type with the Member entity this way
->add('members', 'sonata_type_collection', [
'by_reference' => false,
'label' => 'Members',
'type_options' => ['delete' => true],
'btn_add' => "Add Member",
'required' => false,
'constraints' => $validation['members'],
],
[
'edit' => 'inline',
'inline' => 'table'
])
The member entity has 4 fields, one of which is required.
->add('firstName', TextType::class, [
'label' => 'First Name'
'constraints' => [
new NotBlank(['message' => 'Please enter the name.']),
]
])
If I click the "Add Member" button in the edit view, it adds a new row as expected. At that point, if I change my mind and decide to delete the newly added record, without adding the name, on save it's returning a validation error telling me 'Please enter the name.' on the field.
Shouldn't the delete action have priority over validation?