symfony - Easy Admin 不显示关系
问题描述
- 我正在使用快速通道训练 Symfony 5.2
- 我在第 9 步配置 EASY Admin
- Easy Admin 创建一个用于会议和一个用于评论的 CRUD 控制器(评论属于会议)
- 问题是当我创建一个新的评论时,EasyAdmin 没有建议我选择列表来选择它所属的会议,并且创建以 SQL 异常结束。
解决方案
出于同样的原因,我也被困在这一步!但我在这个链接中找到了解决方案
总之,在Admin/CommentCrudController.php中,您应该添加以下内容:
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
并像这样覆盖函数configureFields:
public function configureFields(string $pageName): iterable
{
return [
FormField::addPanel('Conference'),
AssociationField::new('conference')
->setRequired(true)
->setHelp('help text'),
FormField::addPanel('Comment'),
TextField::new('author')
->setHelp('Your name'),
TextEditorField::new('text', 'Comment')
->setHelp('help text'),
EmailField::new('email', 'Email Address')
->setHelp('Your valid email address'),
DateTimeField::new('createdAt'),
TextField::new('photoFilename')
];
}
现在,它对我来说应该可以正常工作:-)
推荐阅读
- java - 导入 org 包时出错 - 可从多个模块访问
- batch-file - 更改文本文件中的某些列,其余列将使用批处理脚本保留
- mongoose - 具有必需属性和混合属性的 Mongoose 模式
- reactjs - 防止 Material UI Typography Text 超出其父级
- c# - 如何在 C# 中按 ID 对 JSON 数据进行分组
- vue.js - 使用 Vue /Ajax 的 Shopify 客户登录表单
- python - 如何使函数将间隔拆分为“n”个子间隔?
- python - 为什么 SystemButtonFace 在 linux 中没有作为颜色接收,但在使用 tkinter 时在 windows 中接收?
- r - 如何使用 ggplot 为我的线性混合模型正确设置图例?
- c - 在 C 中使用带有两个正双精度的余数会将其变为负数?