开发者

How to display the name of a related model in symfony1.4

I've got a symfony adm开发者_Go百科in model that has a related field (doctrine). In the admin list view it displays the ID instead of the name. How can I change this?

Thanks


If I remember correctly, you can use the name of the relation as fieldname in the displaylist.

But what always works is using a partial. So in your generator.yml:

list:
  display: [id, name, _referred]

And then created _referred.php in your templates folder, and do something like:

<?php echo $modelName->Referred->name; ?>


I see that you already have an accepted answer, but will answer anyway:

Create a __toString() method in the related model. Symfony will automatically use it to output that object, and thus displaying what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜