質問

I want to add an address and telephone number using FOSUserBundle. How can I add a Custom fields, with FOSuserBundle, to have a profile that contains address and telephone number....

役に立ちましたか?

解決 2

the problem is in : when i follow the symfony documentation:https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md in step a) Doctrine ORM User class i have created a folder doctrine contains User.orm.yml:

src/Acme/UserBundle/Resources/config/doctrine/User.orm.yml

Acme\UserBundle\Entity\User: type: entity table: fos_user id: id: type: integer generator: strategy: AUTO

this file crush any update in your entities and update of your database shemea .The solution is to delete this folder.

他のヒント

Create an own user bundle and in the MyCompanyUserBundle.php you set

public function getParent(){
        return 'FOSUserBundle';
}

Then in your new UserBundle you create a User entity and let it extend from the base user of the FOS user bundle:

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="user")
*/
class User extends BaseUser
{

    public function __toString(){
        return $this->firstname . ' ' . $this->lastname . ' (' . $this->email . ')';
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }



}

EDIT

Set the user in the config as well:

fos_user:
        db_driver: orm
        firewall_name: main
        user_class: MyCompany\UserBundle\Entity\User

You don't have to add custom fields but you have to create your own user model.

Read the doc, all is explained: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md#step-3-create-your-user-class

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top