这是我的表单类
class CommentType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('user')
->add('comment')
;
}
public function getName()
{
return 'sample_staticbundle_commenttype';
}
}
我无法获得 getName 函数的作用
最佳答案
在为该表单呈现 Twig 模板时使用它。它允许您通过指定 block 来覆盖默认小部件,但仅限于该特定表单,例如:
{% block sample_staticbundle_commenttype_widget %}
关于php - 函数 getName 在 symfony 2 形式中做什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11406108/