sf_*_*anb 5 symfony-forms symfony
似乎Symfony2 Form组件不处理这种常见情况.以下是我在html中想要的内容

代码如下:
->add('code', 'choice', array(
'choices' => array(
'Food' => array('pizza', 'burger', 'icecream'),
'Music' => array('poney', 'little', 'pocket'),
),
'multiple' => true,
'expanded' => true,
'required' => true
));
Run Code Online (Sandbox Code Playgroud)
这实际上给出了错误的输出:

这很奇怪,因为案件expanded => false处理得当

请问如何处理这个案子?
sf_*_*anb 12
好的,这就是form_theme解决方案
{% block _user_code_widget %}
<div {{ block('widget_container_attributes') }}>
{% for name, choices in form.vars.choices %}
<ul>
<li class="checkbox_category">
<input type="checkbox" class="checkallsub" /> {{ name }}
</li>
{% for key,choice in choices %}
<li class="indent">
{{ form_widget(form[key]) }}
{{ form_label(form[key]) }}
</li>
{% endfor %}
</ul>
{% endfor %}
</div>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
当然缺少额外的js层,但你明白了.
| 归档时间: |
|
| 查看次数: |
4028 次 |
| 最近记录: |