-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix toOne translation fields #30
Fix toOne translation fields #30
Conversation
It's not that so simple as explained elsewhere #25 (comment) & #13 (comment) |
I just applied this to my project and it works like a charm, mind yo explain why it does not work? (Im trying with ManyToOne, maybe the problem if it is ManyToMany?) |
cea93cf
to
2d0dedd
Compare
Let's start again, by adding a failing test... I'm trying to fix it but I always end up in a infinite loop |
2d0dedd
to
8700fb6
Compare
Can you take a look at the proposed solution? @webda2l |
$assocsConfigs[$assocName] = [ | ||
'field_type' => AutoFormType::class, | ||
'data_class' => $class, | ||
'required' => !$nullable, | ||
'required' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I don't change this, association fields are always created empty. Shouldn't this be just required false directly?
if (!$metadata->isAssociationInverseSide($assocName)) { | ||
$associationMapping = $metadata->getAssociationMapping($assocName); | ||
|
||
if (isset($associationMapping['inversedBy'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real fix, the other change is to avoid creating empty objects.
continue; | ||
} | ||
|
||
$class = $metadata->getAssociationTargetClass($assocName); | ||
|
||
if ($metadata->isSingleValuedAssociation($assocName)) { | ||
$nullable = ($metadata instanceof ClassMetadataInfo) && isset($metadata->discriminatorColumn['nullable']) && $metadata->discriminatorColumn['nullable']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't understood this line, discriminatorColumn
is for inheritance, not sure what is the relation with the nullable thing.
aa16114
to
65222a8
Compare
Thanks @jordisala1991, I will check later this weekend with #10 (comment) to try to refresh my memory about this, but it's sound good :) |
Fixing the problem of #10
Also closes: #25 #13