重複の可能性:
フォームの非表示フィールドに値を渡します
非表示のフォーム入力を通過させたいエンティティのIDを知っています。newAction
IDを持っているか、リポジトリからオブジェクトを取得できます。
実在物:
/**
* @var object $target
*
* @ORM\ManyToOne(targetEntity="Acme\TestBundle\Entity\Target")
* @ORM\JoinColumn(name="target_id", referencedColumnName="id", nullable=false)
*/
private $target;
FormType:
->add('target', 'hidden', array('property_path' => 'target.id'))
newAction
私はします:
$target = $em->...->find($id);
$entity->setTarget($target);
しかし、私が固執すると、エラーが発生します:
Warning: spl_object_hash() expects parameter 1 to be object, string given(...)
私が間違っていることは何ですか?