如何在Symfony 5 EasyAdmin 3中显示与其详细信息页面的链接的关联对象?
我有两个实体,即要约和候选人,它们之间有一定的关系。相关代码零件是以下内容:
invor.php:
/**
* @ORM\OneToMany(targetEntity=Candidate::class, mappedBy="offer", orphanRemoval=true)
*/
private $candidates;
public function __construct()
{
$this->candidates = new ArrayCollection();
}
in cantifate.php:
/**
* @ORM\ManyToOne(targetEntity=Offer::class, inversedBy="candidates")
* @ORM\JoinColumn(nullable=false)
*/
private $offer;
in fivecrudcontroller.php:
public function configureFields(string $pageName): iterable
{
return [
ArrayField::new('candidates', new TranslatableMessage('easyadmin.candidates'))
->onlyOnDetail(),
AssociationField::new('candidates', new TranslatableMessage('easyadmin.candidates'))
->onlyOnIndex()
];
}
in candidatecrudcontroller.php:
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('offer', new TranslatableMessage('easyadmin.candidate.offer'))
];
}
我的问题是,在候选人的情况下,EasyAdmin显示了每个候选人链接到其详细信息页面的报价, ,对于报价,它仅显示候选人的不可添加的字符串表示形式,如图像所示:
也可以通过适当的链接显示候选人的适当链接他们的详细信息页面?
I have two entities, Offer and Candidate, with a OneToMany relationship between them. The relevant code parts are the followings:
In Offer.php:
/**
* @ORM\OneToMany(targetEntity=Candidate::class, mappedBy="offer", orphanRemoval=true)
*/
private $candidates;
public function __construct()
{
$this->candidates = new ArrayCollection();
}
In Candidate.php:
/**
* @ORM\ManyToOne(targetEntity=Offer::class, inversedBy="candidates")
* @ORM\JoinColumn(nullable=false)
*/
private $offer;
In OfferCrudController.php:
public function configureFields(string $pageName): iterable
{
return [
ArrayField::new('candidates', new TranslatableMessage('easyadmin.candidates'))
->onlyOnDetail(),
AssociationField::new('candidates', new TranslatableMessage('easyadmin.candidates'))
->onlyOnIndex()
];
}
In CandidateCrudController.php:
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('offer', new TranslatableMessage('easyadmin.candidate.offer'))
];
}
My problem is that while in the case of Candidates EasyAdmin displays the Offer linked to its details page for each Candidate, for the Offers it displays only the non-clickable string representations of the Candidates, as the images show it:
Is it possible to display the Candidates too with their appropriate links to their details page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的,但是您应该为此创建一个自定义模板。
假设您创建了
/templates/admin/field/ffer/detail/candidates.html.twig
。然后,在中,要gresscrudcontroller
需要为候选人
字段*:在模板中,仅生成每个实体的URL:
Yes, it's possible, but you should create a custom template for this.
Let's say, you've created
/templates/admin/field/offer/detail/candidates.html.twig
. Then inOfferCrudController
need to set created template forcandidates
field*:And in template just generate URL for each entity: