函数 getName 以 symfony 2 形式做什么 [英] What does the function getName do in symfony 2 form

查看:31
本文介绍了函数 getName 以 symfony 2 形式做什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的表单类

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

        ;
    }

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

我无法获得 getName 函数的功能

I am not able to get what getName function does

推荐答案

在渲染该表单的树枝模板时使用.它允许您通过指定一个块来覆盖默认小部件,但仅限于该特定表单,例如:

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 %}

这篇关于函数 getName 以 symfony 2 形式做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆