I added a field to the user entity following those instructions : http://symfony.com/doc/current/bundles/FOSUserBundle/overriding_forms.html But the added attribut doesn'nt appears in the form...
My type form :
<?php
namespace PCUserBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RegistrationFormType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('realName');
}
public function getParent() {
return 'fos_user_registration';
}
public function getName() {
return 'pc_user_registration';
}
}
in app config
fos_user:
db_driver: orm
firewall_name: main
user_class: PCUserBundle\Entity\User
registration:
form:
name: pc_user_registration
My extended entity user
<?php
// src/AppBundle/Entity/User.php
namespace PCUserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="text",nullable=true)
*/
protected $realName;
public function __construct() {
parent::__construct();
// your own logic
}
/**
* Set realName
*
* @param string $realName
*
* @return User
*/
public function setRealName($realName) {
$this->realName = $realName;
return $this;
}
/**
* Get realName
*
* @return string
*/
public function getRealName() {
return $this->realName;
}
}
in the service file of my bundle :
services:
app.form.registration:
class: PCUserBundle\Form\RegistrationFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: pc_user_registration }
The form appears but without the field real name...