문제

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