Reputation: 21
I try to insert into association table between 2 tables, I have this error :
Catchable Fatal Error: Argument 1 passed to Acme\HomeBundle\Entity\AuthUsergroup::setLogin() must be an instance of Acme\HomeBundle\Entity\AuthUser, string given, called in /var/www/html/prj/src/Acme/HomeBundle/Controller/UserController.php on line 73 and defined
and that line 73 is : $aug->setLogin($my_id); and this function comes from :
/**
* Set login
*
* @param \Acme\HomeBundle\Entity\AuthUser $login
*
* @return AuthUsergroup
*/
public function setLogin(\Acme\HomeBundle\Entity\AuthUser $login = null)
{
$this->login = $login;
return $this;
}
Upvotes: 1
Views: 43
Reputation: 813
The error is pretty self explanatory : the setLogin()
methods expects a AuthUser object, and you are giving it a string. You have to pass to do something like this :
$newAuth = new AuthUser();
// assuming the AuthUser class has a setName() method
$newAuth->setName($my_id);
// You pass a AuthUser object -> no more exception thrown
$aug->setLogin($newAuth);
Hope this helps.
Upvotes: 1