cesurapp / pd-user

Simple user management system for Symfony 5.
MIT License
24 stars 5 forks source link

On event how to set in profile? #9

Closed xorgxx closed 4 years ago

xorgxx commented 4 years ago

Hi i'm trying to set compagny, and some of my entity profile, in event

        public function onRegisterBefore( UserEvent $userEvent)
        {
            $user = $userEvent->getUser();
            $user->getProfile()->setAddress("dede");
            $user->getProfile()->setCompagny("dede");
        }

i get error Call to a member function setAddress() on null i want to set this form value how was get by api before registration and set in the session.

how do i can do this?

cesurapp commented 4 years ago

You may receive an error because the User's Profile has not been created yet.

cesurapp commented 4 years ago

$profile = new Profile(); $profile->setAddress('dede')

$user->setProfile($profile);

Try this.

xorgxx commented 4 years ago

i will try tomorrow thank's

xorgxx commented 4 years ago

it's functional as you ask to do.