<?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\OptionsResolverInterface;
{% endblock use_statements %}

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

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

        ;
    }
    {% endif %}

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

    /**
     * @return string
     */
    public function getName()
    {
        return '{{ form_type_name }}';
    }
{% endblock class_body %}
}
