Aktywne Wpisy
Teuvo +7
ile mieliście lat gdy pierwszy raz byliście pijani?
prawiczek92 +38
Ja idę z nią na sushi a wy zazdrośni #przegryw #przegrywpo30tce #podrywajzwykopem #pokazmorde #gdansk
Skopiuj link
Skopiuj linkWykop.pl
W projekcie nie chce to działać więc próbowałem to zrobić na demie ale też nie idzie.
Błąd
Found entity of type Acme\DemoBundle\Entity\FosUserUser on association Acme\DemoBundle\Entity\OmEntries#user, but expecting Acme\DemoBundle\Entity\OmEntries
Kod, w skrócie http://pastebin.com/1kmV4Aag
Entity\Entry.php
/**
* @var \FosUserUser
*
* @ORM\ManyToOne(targetEntity="FosUserUser")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user", referencedColumnName="id")
* })
*/
private $user;
/**
* Set user
*/
public function setUser(\Acme\DemoBundle\Entity\FosUserUser $user = null)
{
$this->user = $user;
return $this;
}
Akcja w kontrolerze
$newentry = new Entry;
$newentry->setEntry('test');
$user = $this->getDoctrine()->getRepository('AcmeDemoBundle:FosUserUser')->find($this->getUser()->getId());
$new_entry->setUser($user);
#symfony2 #symfony
po co masz coś takiego:
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user", referencedColumnName="id")
* })
zostaw tylko
@ORM\JoinColumn(name="user", referencedColumnName="id")
masz takie entity: Acme\DemoBundle\Entity\OmEntries
co pokazuje: php app/console doctrine:schema:validate ?
[Mapping] OK - The mapping files are correct.