I'm trying to use sonata user bundle. I have to add some fields.
I have seen a folder Application\Sonata\UserBundle which is created with the sonata user bundle installation.
I have then tried to modify the Entity\User.php file:
<?php
namespace Application\Sonata\UserBundle\Entity;
use Sonata\UserBundle\Entity\BaseUser as BaseUser;
class User extends BaseUser
{
/**
* @var integer $id
*/
protected $id;
/**
* Get id
*
* @return integer $id
*/
public function getId()
{
return $this->id;
}
For example adding:
<?php
namespace Application\Sonata\UserBundle\Entity;
use Sonata\UserBundle\Entity\BaseUser as BaseUser;
class User extends BaseUser
{
/**
* @var integer $id
*/
protected $id;
/**
* Get id
*
* @return integer $id
*/
public function getId()
{
return $this->id;
}
/**
* @var String $nom
*/
protected $nom;
/**
* Get nom
*
* @return string
*/
public function getNom() {
return $this->nom;
}
But my database is not updated and nothing work. Do you knows how to do that?
Alternatively I have also tried to write in the UserAdmin.php file:
$formMapper
->with('General')
->add('username')
->add('email')
->add('plainPassword', 'text', array(
'required' => (!$this->getSubject() || is_null($this->getSubject()->getId()))
))
->add('nom')
->end()
->with('Groups')
->add('groups', 'sonata_type_model', array(
'required' => false,
'expanded' => true,
'multiple' => true
))
->end()
But I have the following error:
Please define a type for field `Prenom` in `Sonata\UserBundle\Admin\Entity\UserAdmin`
Thanks Best regards