1
我有這樣的自定義表單字段自定義表單字段如何獲得表單變量在Symfony2中
{# src/Acme/DemoBundle/Resources/views/Form/fields.html.twig #}
{% block gender_widget %}
{% spaceless %}
{% if expanded %}
<ul {{ block('widget_container_attributes') }}>
{% for child in form %}
<li>
{{ form_widget(child) }}
{{ form_label(child) }}
</li>
{% endfor %}
</ul>
{% else %}
{# just let the choice widget render the select tag #}
{{ block('choice_widget') }}
{% endif %}
{% endspaceless %}
{% endblock %}
這使得該複選框。但我無法找到如何獲得複選框的值
即即child.form.value
不起作用。
假設我有在表單中命名爲任務的實體。
我怎樣才能得到taskid的值。
像
child.form.vars.task.id