KnpLabs / DoctrineBehaviors

Doctrine2 behavior traits that help handling Blameable, Loggable, Sluggable, SoftDeletable, Uuidable, Timestampable, Translatable, Tree behavior
http://knplabs.com
MIT License
916 stars 299 forks source link

translations should not be null validation error #749

Closed tacman closed 11 months ago

tacman commented 11 months ago

I recently added

#[Assert\EnableAutoMapping]

to a class that implements TranslatableInterface, but now when I try to validate an entity, I get

object(App\Entity\Project).translations:                            
   This value should not be null. (code ad32d13f-c3d4-423b-909a-857b961eb720) 

I can't find where translations is being set to NotNull, though I suspect it's in Defaults.

bin/console debug:valid App\Entity\Project

|translations | Symfony\Component\Validator\Constraints\NotNull | Default, Project | [ | | | | | "message" => "This value should not be null.", | | | | | "payload" => null | | | | | ]

I think null is valid, and I can't figure out how to unset this, or even how to set it to an acceptable default (an empty collection?)

tacman commented 11 months ago

The same thing is happening with currentLocale, even though that's not persisted.

tacman commented 11 months ago

I think I'm going down the wrong path here, so I'm closing this.