Skip to content

Instantly share code, notes, and snippets.

@maninhat
Created February 22, 2019 11:50
Show Gist options
  • Save maninhat/76ce6020cb2bf6521031a66481199323 to your computer and use it in GitHub Desktop.
Save maninhat/76ce6020cb2bf6521031a66481199323 to your computer and use it in GitHub Desktop.
Symfony Fieldset form type
{% block fieldset_row %}
<fieldset {{ block('widget_container_attributes') }}>
<legend{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</legend>
{%- if form.parent is empty -%}
{{ form_errors(form) }}
{%- endif -%}
{{- block('form_rows') -}}
{{- form_rest(form) -}}
</fieldset>
{% endblock %}
<?php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FieldsetType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefault('inherit_data', true);
}
public function getBlockPrefix()
{
return 'fieldset';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment