Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the function getName do in symfony 2 form

Tags:

php

symfony

This is my form class

class CommentType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder
            ->add('user')
            ->add('comment')

        ;
    }

    public function getName()
    {
        return 'sample_staticbundle_commenttype';
    }
}

I am not able to get what getName function does

like image 551
Mirage Avatar asked Jul 10 '12 03:07

Mirage


1 Answers

It is used when rendering the twig templates for that form. It lets you override the default widgets but only for that particular form by specifying a block like, for example:

{% block sample_staticbundle_commenttype_widget %}
like image 58
MDrollette Avatar answered Oct 05 '22 18:10

MDrollette