我写了一个表单类型扩展了forsuser ProfileFormType,但是每次我在模板中渲染它时,表单顶部应该总是有一个标签“用户”。我发现它来自原始 fosuser ProfileFormType:
namespace FOS\UserBundle\Form\Type;
use .....
class ProfileFormType extends AbstractType
{
private $class;
/**
* @param string $class The User class name
*/
public function __construct($class)
{
$this->class = $class;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$child = $builder->create('user', 'form', array('data_class' => $this->class));
$this->buildUserForm($child, $options);
.......
如果我为此表单字段添加属性,例如:
$child = $builder->create('user', 'form', array('label'=>'some info','data_class' => $this->class));
它可以工作,但它不利于修改原始文件,如何在我的自定义表单类型或渲染时在模板中修改它?