EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Required fields don't work with useEntryCrudForm()

Open simoheinonen opened this issue 2 years ago • 2 comments

Describe the bug

Required fields don't work with useEntryCrudForm()

To Reproduce

// FooCrudController
TextField::new('code')->setRequired(true);
// SomeOtherCrudController
CollectionField::new('foos')->useEntryCrudForm();

leads to mysql error instead of warning in the UI like it does normally

simoheinonen avatar May 17 '23 10:05 simoheinonen

Add it on main form too:

CollectionField::new('foos')->setRequired(true)->useEntryCrudForm();

Geolim4 avatar Aug 11 '24 14:08 Geolim4

@Geolim4 thx, now it works for me

dwd-akira avatar Sep 01 '24 21:09 dwd-akira

Hello there :)

I jump into this thread cause I'm facing the same issue as @dwd-akira but the solution that you gave @Geolim4 doesn't suit my case.

Same example, but I don't want to force the user to add an entity in the 'foos' field. I want the 'code' field to be required ONLY when the user try to add an entity in the 'foos' field, without making this add mandatory.

I find strange that we need inheritance on the parent for the required attribute.

Any idea ?

PGeekS avatar Dec 29 '24 22:12 PGeekS

@PGeekS put a @valid constraint on your relationship (ManyToMany or OneToMany) property.

Geolim4 avatar Dec 29 '24 22:12 Geolim4

This issue has been automatically closed as part of our end-of-year repository maintenance. As an open-source project with limited resources, we need to focus our efforts on the most current and impactful issues. If this feature or bug is still relevant to you, please create a new issue. For bugs, include a detailed reproducer, and for features, provide a clear explanation of your request. Thank you for your understanding and for supporting our project!

javiereguiluz avatar Dec 31 '24 12:12 javiereguiluz