The form should automatically display the value user-> id in the selected object selection field. For example, if you have a Computer object that has an OnetoOne relationship with a User object in the connection table called "computer_users":
class Computer{
private $user;
private $computerUsers;
public function getUser(){
return $computerUsers->getUser();
}
private function getComputerUser(){
return $this->$computerUsers;
}
}
"" user- > id "" "", .
, SetData():
$computerForm = $this->createForm( new ComputerForm(), $computer );
$user = $computer->getComputerUser()->getUser();
$computerForm->get('user')->setData( $user );
return $this->render( 'AcmeBundle:Computer:edit.html.twig'
, array( 'computer' => $computer
, 'computerForm' => $computerForm->createView()
)
);