Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with generatorBundle and FosUser : No mapping found for field 'roles' #186

Open
rpostolov opened this issue Jul 29, 2015 · 0 comments

Comments

@rpostolov
Copy link

Hi everybody !

I have some problem using FOSUserBundle.

I am on symfony 2.7.1 and i installed fosuserbundle "~2.0@dev"

I create bundle User and admin but when i try to go to edit admin or else i have this problem

No mapping found for field 'roles' on class 'Ip\UserBundle\Entity\User'.

Can someone help me cause i'm stuck on this bug a long time already.

I posted this issue on FosUser Repository but maybe it's an problem from GeneratorBundle.

I use FosUser on Entity User :

use FOS\UserBundle\Model\User as BaseUser;

use Doctrine\ORM\Mapping as ORM;

/**
 * User
 *
 * @ORM\Table(name="user")
 * @ORM\Entity(repositoryClass="Ip\UserBundle\Entity\UserRepository")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"admin" = "Ip\AdminBundle\Entity\Admin", "customer" = "Ip\CustomerBundle\Entity\Customer"})
 * 
 * @ORM\HasLifecycleCallbacks() 
 */
abstract class User extends BaseUser

And Here is for Entity Admin :

namespace Ip\AdminBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use PUGX\MultiUserBundle\Validator\Constraints\UniqueEntity;

use Ip\UserBundle\Entity\User as User;

/**
 * Admin
 *
 * @ORM\Table(name="admin")
 * @ORM\Entity(repositoryClass="Ip\AdminBundle\Entity\AdminRepository")
 * @UniqueEntity(fields = "username", targetClass = "Ip\UserBundle\Entity\User", message="fos_user.username.already_used")
 * @UniqueEntity(fields = "email", targetClass = "Ip\UserBundle\Entity\User", message="fos_user.email.already_used")
 */
class Admin extends User

Here is my configuration in config.yml

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"

        entity_managers:
            default:
                auto_mapping: true
                filters:
                    oneLocale:
                        class: A2lix\I18nDoctrineBundle\Doctrine\ORM\Filter\OneLocaleFilter
                        enabled: true

#AdminGenerator
admingenerator_generator:
    generator_cache: global_cache.provider
    # choose  and enable at least one
    use_propel:           false
    use_doctrine_orm:     true
    use_doctrine_odm:     false
    overwrite_if_exists: false
    base_admin_template: AdmingeneratorGeneratorBundle::base_uncompressed.html.twig
    #dashboard_welcome_path: root vers le dashboard de l'admin
    #dashboard_route:     MyDashboard_path
    generator_cache: global_cache.provider
    login_route: fos_user_security_login
    logout_route: fos_user_security_logout
    twig:
        use_form_resources: true
        use_localized_date: false
        date_format: Y-m-d
        datetime_format: Y-m-d H:i:s
        localized_date_format: medium
        localized_datetime_format: medium
        number_format:
            decimal: 0
            decimal_point: .
            thousand_separator: ,
    templates_dirs: []
    stylesheets: []
    javascripts: []

# Fos Users    
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Ip\UserBundle\Entity\User
    service:
        user_manager: pugx_user_manager

pugx_multi_user:
  users:
    admin:
        entity: 
          class: Ip\AdminBundle\Entity\Admin
#          factory: 
        registration:
          form: 
            type: Ip\AdminBundle\Form\Type\RegistrationAdminFormType
            name: fos_user_registration_form
            validation_groups:  [Registration, Default]
          template: IpAdminBundle:Registration:admin.form.html.twig
        profile:
          form:
            type: Ip\AdminBundle\Form\Type\ProfileAdminFormType
            name: fos_user_profile_form
            validation_groups:  [Profile, Default] 
    customer:
        entity: 
          class: Ip\CustomerBundle\Entity\Customer
        registration:
          form: 
            type: Ip\CustomerBundle\Form\Type\RegistrationCustomerFormType
          template: IpCustomerBundle:Registration:customer.form.html.twig
        profile:
          form: 
            type: Ip\CustomerBundle\Form\Type\ProfileCustomerFormType

admingenerator_user:
     login_template: AdmingeneratorGeneratorBundle::base_admin.html.twig

Thanks a lot for your help !

sescandell added a commit that referenced this issue May 23, 2016
Issue #186 : allows "array" db type to be used with a collection form type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant