<?php

namespace {{ namespace }}\Form{{ entity_namespace ? '\\' ~ entity_namespace : '' }};

{% block use_statements %}
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
{% endblock use_statements %}

{% block class_definition %}
class {{ form_class }} extends AbstractType
{% endblock class_definition %}
{
{% block class_body %}
    {%- if fields|length > 0 %}
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            {%- for field in fields -%}

                ->add('{{ field }}')

            {%- endfor %};
    }
    {% endif %}

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => '{{ namespace }}\Entity{{ entity_namespace ? '\\' ~ entity_namespace : '' }}\{{ entity_class }}'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return '{{ form_type_name }}';
    }

{# BC with Symfony 2.7 #}
{%- if get_name_required %}
    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return $this->getBlockPrefix();
    }
{% endif %}

{% endblock class_body %}
}
