I have created an ORM user class and I added a new attribute called "name". I have created a new RegistrationFormType also. The problem is the registration form display only the new field "name" and other fields (email, usreneme, password ') provided by FOSuserBundle are hidden.
// src/Boutique/UserBundle/Form/RegistrationFormType.php
<?php
namespace Boutique\UserBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
class RegistrationFormType extends BaseType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Boutique\UserBundle\Entity\User'
));
}
public function getName()
{
return 'boutique_user_registration';
}
}
config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: Boutique\UserBundle\Entity\User
registration:
confirmation:
from_email: # Use this node only if you don't want the global email address for the confirmation email
address: [email protected]
sender_name: no-reply
enabled: false # change to true for required email confirmation
template: FOSUserBundle:Registration:email.txt.twig
form:
type: boutique_user_registration
name: fos_user_registration_form
validation_groups: [Registration, Default]
services.yml
services:
boutique_user.registration.form.type:
class: Boutique\UserBundle\Form\RegistrationFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: boutique_user_registration }