【发布时间】:2014-02-20 14:04:41
【问题描述】:
我正在尝试删除在 FOSUserBundle 中编辑用户名的选项。
我的ProfileFormType.php 如下所示:
<?php
namespace ACME\MemberBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\Validator\Constraint\UserPassword as OldUserPassword;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use FOS\UserBundle\Form\Type\ProfileFormType as BaseType;
class ProfileFormType extends BaseType {
protected function buildUserForm(FormBuilderInterface $builder, array $options) {
parent::buildUserForm($builder, $options);
$builder->remove('username');
}
public function getName()
{
return 'acme_member_edit_profile';
}
}
我还将它注册为服务并编辑了config.yml 文件。但是,当我提交表单时,我会收到以下警报消息:
此表单不应包含额外字段。
【问题讨论】:
标签: php symfony fosuserbundle