Skip to content

Form validation, entity property does not exist for extended classes #31859

@IMSDeveloper

Description

@IMSDeveloper

Symfony version(s) affected: 4.3.0

Description
I've updated a project from 4.2.0 to 4.3.0 and now the $form->handleRequest($request) call is triggering an error on an entity which extends from another i.e. joined inheritance. The error I'm getting is 'Property "password" does not exist in class "App\Entity\Organisations\User"'. In my project that entity extends \App\Entity\Users\User which does have the "password" property along with a relevant getter and setter. The base user class implements Symfony\Component\Security\Core\User\UserInterface

How to reproduce
Base "User" class in "\App\Entity\Users\User"

class User implements UserInterface
{
    // ...
    /**
     * @ORM\Column(type="string", length=64, nullable=true)
     */
    private $password;
    // ...
}

Extended "User" class in "App\Entity\Organisations\User"

class User extends \App\Entity\Users\User 
{
    // nothing relevant here
}

In a controller using a regular form, error is triggered via this call upon form submission.
$accountForm->handleRequest($request);

The error I'm getting is

Property "password" does not exist in class "App\Entity\Organisations\User"

Possible Solution
Not aware of any solutions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions