我有一个Symfony应用程序,它具有以下形式:
$builder->add('test', ChoiceType::class, [
'choices' => ['a' => 1, 'b' => 2],
'multiple' => false,
'mapped' => false,
'expanded' => true,
]);
我用{{ form_widget(form.test)}}显示它,我得到:
<div id="task_test">
<div class="form-check">
<input type="radio" id="task_test_0" name="task[test]" required="required" class="form-check-input" value="1">
<label class="form-check-label required" for="task_test_0">a</label></div>
<div class="form-check">
<input type="radio" id="task_test_1" name="task[test]" required="required" class="form-check-input" value="2">
<label class="form-check-label required" for="task_test_1">b</label>
</div>
</div>
我想得到这个HTML代码:
<div id="task_test">
<div class="form-check d-inline-block custom-control custom-radio mr-1">
<input type="radio" id="task_test_0" name="task[test]" required="required" class="form-check-input custom-control-input" value="1">
<label class="form-check-label required custom-control-label" for="task_test_0">a</label></div>
<div class="form-check d-inline-block custom-control custom-radio">
<input type="radio" id="task_test_1" name="task[test]" required="required" class="form-check-input custom-control-input" value="2">
<label class="form-check-label required custom-control-label" for="task_test_1">b</label>
</div>
</div>
1条答案
按热度按时间juud5qan1#
这将不是你想要的一样,但至少它接近它
如果您想要精确html输出,那么您必须编辑您的供应商模板