I am trying to remove the option to edit the username in the FOSUserBundle.
My ProfileFormType.php
looks as follows:
<?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';
}
}
I also registered it as service and edited the config.yml
file. However, when I submit the form I get the following alert message:
This form should not contain extra fields.