forms - 我希望我的 entityType 的每个选择都显示该选择的许多属性 Symfony 4
问题描述
这是我的问题,我正在使用 Symfony 4。我创建了一个表单并添加了另一个表单类型的集合。它工作得很好,但现在,我想将 Collection 更改为 EntityType。
这是我的第一个代码
$builder
->add('id_etudiant', EtudiantSecondType::class)
->add('id_diplome', DiplomeType::class)
->add('suivres', CollectionType::class, [
'entry_type' => SuivreType::class,
'entry_options' => ['label' => false],
]) ;
现在我想把它改成这样
$builder
->add('id_etudiant', EtudiantSecondType::class)
->add('id_diplome', DiplomeType::class)
->add('suivres', EntityType::class, [
'class' =>SuivreType::class,
'block_name'=>'app_one_module_type',
'block_prefix'=>'app_one_module',
'mapped'=>false,
'expanded'=>true,
'multiple'=>true,
'choice_label'=>function(Suivre $suivre){
return "";
},
])
;
我认为我们不能在 EntityType 中指定表单类型,所以我添加了我需要的树枝部分,但它不起作用。我得到了结果,但不是我声明的树枝格式:
'block_name'=>'app_one_module_type',
'block_prefix'=>'app_one_module',
解决方案
推荐阅读
- sql - 我怎样才能写出同月雇佣的员工和订单?
- r - 对返回原始维数的数组应用函数
- nginx - RTMP 代理裁剪原始视频并将其发送到另一个 RTMP 服务器
- c# - ConnectAsync 阻止 UI
- javascript - webapi中的HttpPost方法中的webapi cors错误
- google-apps-script - 未使用 Google 应用脚本打开 Google 表格时如何从其他来源更新导入范围数据
- python - Scrapy 在 shell 中有效,但在代码中无效
- java - 为什么在 Kafka 集群未运行的情况下创建主题时 AdminClient 没有失败?
- ios - 我应该如何使用 AudioFileStreamOpen Xcode 12
- c# - 在特定时间运行任务(毫秒)