Skip to content

[PropertyAccess][DX] Exception mention that some methods didn't exist although they did #18694

Closed
@nykopol

Description

@nykopol

With the simple case of 2 entities with a manyToMany relation. If we use a form field not multiple to set the relation, the PropertyAccess throw an exception :

Neither the property "groupes" nor one of the methods "addGroup()"/"removeGroup()", 
"addGroupe()"/"removeGroupe()", "setGroupes()", "groupes()", "__set()" or "__call()" exist
and have public access in class "AppBundle\Entity\User"

But if we look at the Entity, the methods addGroupe and removeGroupe exists and are public.
The exception is raised because in the method writeProperty these too methods are used only if the value is an array or traversable witch is not the case if the form field is not multiple.

It would be more easy to debug this situation if we check the presence of the adder and remover methods. Then if this too methods exists the exception should point the fact that in this situation, the expected value is an array or a traversable instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)PropertyAccess

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions