Is there any way to override/remove "social fields" and others in baseuser.orm.xml?

1,557 views
Skip to first unread message

Igor Davidov

unread,
Jun 11, 2012, 6:15:32 AM6/11/12
to sonata-devs
First of all thank you all for this wonderful bundle!

I am having trouble trying to figure this out for days and any help
would be much appreciated.
I am integrating sonata-admin + fosuser in our existing project as an
upgrade from symfony 1 to symfony 2. I don't know why exactly you have
created baseuser with so much additional fields (which I usually hold
in users profile) and it's causing me problems. I don't need those
fields and would like to remove them, but don't want to edit
"baseuser.orm.xml".

As I read there is no way to replace mapping of one bundle in
Doctrine. Am I stuck here or there is some way I can remove those
"social fields" and others from BaseUser?

Regards

Thomas Rabaix

unread,
Jun 11, 2012, 6:37:56 AM6/11/12
to sonat...@googlegroups.com
Yes, for now you are stuck with these fields. I need to figure out the best solution between mininum features (lastname, gender, etc ...) and extra features (social fields).

Actually, you are not stuck as you can create a custom User class with your own fields. But this is not clearly documented.


--
You received this message because you are subscribed to the Google Groups "sonata-devs" group.
To post to this group, send email to sonat...@googlegroups.com.
To unsubscribe from this group, send email to sonata-devs...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sonata-devs?hl=en.




--
Thomas Rabaix
http://rabaix.net | http://sonata-project.org

Pierre de LESPINAY

unread,
Jul 2, 2012, 10:16:30 AM7/2/12
to sonat...@googlegroups.com
I used SonataEasyExtends to extend the user bundle, but from this extension I don't know how to remove certain user fields.
Do I have to redefine all the needed fields into Application/Sonata/Entity/User.php ?

Igor Davidov

unread,
Jul 2, 2012, 10:24:51 AM7/2/12
to sonat...@googlegroups.com

I don't believe you can do that since these are hard-coded. We decided to use Sonata w/o sonata/user and easyextends and to use just FOSUser bundle.
Which again led us to series of problems with different sonata-related bundles expecting to have sonata-user and sonata-roles.
Now we have frozen Sonata Admin until it's stable enough since we use Symfony 2.0...

Thomas Rabaix

unread,
Jul 11, 2012, 7:09:13 PM7/11/12
to sonat...@googlegroups.com
@Igor, you can redefine the user class if you want, so you are free to remove the default fields and you can do the same for the UserAdmin, just change the class through the parameter setting [1].


[1] https://github.com/sonata-project/SonataUserBundle/blob/2.0/Resources/config/admin_orm.xml#L8

--
You received this message because you are subscribed to the Google Groups "sonata-devs" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sonata-devs/-/yy7b76Ds6tgJ.

To post to this group, send email to sonat...@googlegroups.com.
To unsubscribe from this group, send email to sonata-devs...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sonata-devs?hl=en.

the Whole Life to Learn

unread,
Nov 27, 2012, 11:29:24 AM11/27/12
to sonat...@googlegroups.com
I don't know yet if it is possible to remove social fields... from the database, but it is possible not to show them in the administration interface.
You must add the following lines in config.yml, correct the path to your application and overload their model entity in your bundle

In Symfony 2.0:

parameters:
    sonata.user.admin.user.class:              Application\Sonata\UserBundle\Admin\Entity\UserAdmin

In Symfony 2.1:

sonata_user:
    admin:                  # Admin Classes
        user:
            class:          Application\Sonata\UserBundle\Admin\Entity\UserAdmin


You can also change the field that are displayed. Add the following lines in config.yml, correct the path and overload the files in your bundle.

In Symfony 2.0:

parameters:
    sonata.user.form.type.security_roles.class: Application\Sonata\UserBundle\Form\Type\SecurityRolesType
    sonata.user.profile.form.type.class:            Application\Sonata\UserBundle\Form\Type\ProfileType


In Symfony 2.1:

sonata_user:
    profile:  # Profile Form (firstname, lastname, etc ...)
        form:
            type:               sonata_user_profile



I hope I helped a bit and that my answer is comprehensive!


Regards

Edwin Ibarra

unread,
Jan 4, 2013, 6:37:36 PM1/4/13
to sonat...@googlegroups.com
To remove the fields created by SUB you need to create your own User Entity... you can do that editing the file Application\Sonata\UserBundle\Entity and replacing the BaseUser from Sonata\UserBundle\Entity\User to FOS\UserBundle\Entity\User.

Important: remember to implement the Sonata\UserBundle\Model\UserInterface in the User Entity.
Reply all
Reply to author
Forward
0 new messages