如果我不需要,如何取消在 twig 中显示表单字段?
<p>Form: <br>
$form ->add("rxOriginCode", ChoiceType::class, [<br>
"label" => "Rx Origin",<br>
"required" => true,<br>
"choices" => <br>PrescriptionOriginCode::getDictionary(EnumFactory::FLAG_SHORT),<br>
"mapped" => false,<br>
"data" => $data->getRx()->getRxOriginCode(),
答案 0 :(得分:0)
如果要逐个显示元素,方法form_end
中有一个参数可以防止Twig生成您没有显示的元素:
{{ form_end(form, {'render_rest': false}) }}
http://symfony.com/doc/current/reference/forms/twig_reference.html#form-end-view-variables