私は次の飛行をした実体を持っています:
/**
* @ORM\ManyToOne(targetEntity="Document", inversedBy="posts")
* @ORM\JoinColumn(name="document_id", referencedColumnName="id")
*/
protected $image;
これは次の方法で取得します。
public function indexAction() {
$posts = $this->getDoctrine()
->getRepository('airpaprcms2Bundle:Post')
->findByPageType(1);
if (!$posts) {
throw $this->createNotFoundException('No posts in Database!');
}
return $this->render('airpaprcms2Bundle:Default:index.html.twig', array('posts' => $posts));
}
小枝内のマップされたオブジェクトフォームのプロパティにアクセスするにはどうすればよいですか?試しpost.image.file
ました(マップされたエンティティドキュメントにはプロパティファイルがあります)
{% for post in posts %}
<div>
<h1>
<a href="{{ path('_view', {'slug': post.slug}) }}">{{ post.title }}</a>
</h1>
<p>{{ post.text }}</p>
<img src="{{ post.image.name }}" alt="{{ post.title }}" />
</div>
{% endfor %}
次のエラーメッセージが表示されます。
Item "file" for "" does not exist in airpaprcms2Bundle:Default:index.html.twig at line 11
マップされたドキュメントプロパティにアクセスするための正しい構文は何ですか?