提问人:Vincent Hoogstraten 提问时间:8/30/2023 最后编辑:DarkBeeVincent Hoogstraten 更新时间:8/30/2023 访问量:28
Symfony表单的渲染问题 CollectionType 中新实体的 ChoiceType
Rendering issue for Symfony forms ChoiceType for a new entity in a CollectionType
问:
在我的 Web 应用程序中,我可以创建/编辑/删除班次计划中的班次。这些班次将作为表加载。 现在的问题是,在我的日程安排中创建新班次(现有班次没有此问题)时,下拉列表呈现不正确:
我的表单如下所示:
轮班时间表:
$builder
->add('planningShifts', CollectionType::class, [
'entry_type' => ShiftFormType::class,
'entry_options' => [
'label' => false,
'numberOfWeeks' => $options["data"]->getNumberOfWeeks(),
],
'label' => false,
'allow_add' => true,
'allow_delete' => true,
])
此计划中的单个班次 (ShiftFormType):
$weekChoices = [];
for ($i = 1; $i <= $options['numberOfWeeks']; $i++) {
$weekChoices[$i] = $i;
}
$builder
->add('weeks', ChoiceType::class, [
'choices' => $weekChoices,
'required' => false,
'multiple' => true, //Note: When this value is false I don't have the render issue, but of course I need this to accept multiple options.
]);
我的树枝是这样呈现的:
<td class="cel-edit">
{{ form_widget(shift.weeks) }}
</td>`
我希望对于新的班次,下拉列表将正确加载。
答: 暂无答案
评论