私はsymfony2を使用しています。私は、小枝でデフォルトのdivスタイルフォームブロックをオーバーライドしようとしています。Symfony2フォームテーマの作成 - フィールドセットとリストスタイル
まず、fieldsetとlist(ul - > li)アプローチの実装があるか知っていますか?
私はsymfony2を使用しています。私は、小枝でデフォルトのdivスタイルフォームブロックをオーバーライドしようとしています。Symfony2フォームテーマの作成 - フィールドセットとリストスタイル
まず、fieldsetとlist(ul - > li)アプローチの実装があるか知っていますか?
http://symfony.com/doc/2.0/cookbook/form/form_customization.html
私はthooseの実装を認識していないですが、あなたはそれらを作るとプル要求を開くことが歓迎されています。
デフォルトでは、Twigはフォームをレンダリングするときにdivレイアウトを使用します。ただし、フォームは表レイアウトでレンダリングできます。このようなレイアウトに使用するform_table_layout.html.twigリソースを使用します。私が持っている
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->setAttribute('fieldsets',
array(
array(
'legend' => 'film.group.date',
'content'=> array(
'theaters_release_date',
'storage_media_release',
'storage_media_release_date',
'vod_release_date'
)),
array(
'legend' => 'film.group.country',
'content'=> array('countries')),
));
}
:タイプで
:現時点では
# app/config/config.yml
twig:
form:
resources: ['form_table_layout.html.twig']
を、私はこのようなフィールドセットのサポートを実装しましたビューの属性を使用するfieldset.html.twigという名前のテンプレート:
{% macro fieldset_block(fieldset, form) %}
<fieldset{% if fieldset.subform is defined %} class="{{ fieldset.subform }}"{% endif %}>
<legend>{{fieldset.legend | trans }}</legend>
{% if fieldset.content is defined%}
{% for row in fieldset.content %}
{{ form_row(form[row]) }}
{% endfor %}
{% endif %}
{% if fieldset.subform is defined %}
{# Couldn't get some recursivity (simply call form widget) here... too bad #}
{% if form[fieldset.subform].get('attr').fieldsets is defined %}
{% for subfieldset in form[fieldset.subform].get('attr').fieldsets %}
{{ _self.fieldset_block(subfieldset, form[fieldset.subform]) }}
{% endfor %}
{% else %}
{% for row in form[fieldset.subform] %}
{{ form_row(row) }}
{% endfor %}
{% endif %}
{% endif %}
{% if fieldset.items is defined%}
{% for fieldset in fieldset.items %}
{{ _self.fieldset_block(fieldset, form) }}
{% endfor %}
{% endif %}
</fieldset>
{% endmacro %}
{% block form_widget %}
{% for fieldset in form.get('attr').fieldsets %}
{{ _self.fieldset_block(fieldset, form) }}
{% endfor %}
{% endblock %}
ここはsimpですleフィールドセットの例: https://gist.github.com/spcmky/8512371
divをリストに置き換えるには、form_widget_compoundとform_rowsを参照してください。できること:
{% block fieldset_widget %}
{% spaceless %}
<fieldset {{ block('widget_container_attributes') }}>
{% if title is defined %}<legend>{{ title }}</legend>{% endif %}
<ul>
{% for child in form %}
<li>
{{ form_widget(child) }}
</li>
{% endfor %}
</ul>
</fieldset>
{% endspaceless %}
{% endblock %}