Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ModelAdmin (add member to group)


Go to End


7 Posts   4031 Views

Avatar
dendeffe

Community Member, 135 Posts

10 February 2010 at 2:56pm

I'm using $group->Members()->add($designer); to add users who register on the front end to the correct group. These designers (extension of Member class) are also managed through ModelAdmin. How would I have ModelAdmin add a new designer to the correct group when a new one is created?

Avatar
teejay

Community Member, 63 Posts

11 February 2010 at 12:16pm

Hi dendeffe,

could u pls post abit more code so that this a bit more transparent ?

:)

Avatar
dendeffe

Community Member, 135 Posts

11 February 2010 at 1:48pm

Hi Teejay,

I have a Designer Class which extends Member. I have another Class RegisterPage which has this code:

http://pastie.org/819294

It adds my newly created designer to the correct group. The designers are also editable in the backend through ModelAdmin. I don't have any idea of how to add the Designer to the correct group when I create one there. I can add a field that lists Group, but when I select one there, the Designer isn't added to the selected group.

Avatar
teejay

Community Member, 63 Posts

11 February 2010 at 2:25pm

maybe I am wrong but does the add method just relations ? when u add something it creates a relation entry in the db. Do u have a many_many relation to a designer in your group class ?

did u overwrite the belongs_many_many static of member ?

did u try $designer->write(); before u add it ??

Avatar
dendeffe

Community Member, 135 Posts

11 February 2010 at 10:23pm

Hmmm I haven't edited group, because it's a Class in Sapphire itself

Avatar
meganub

Community Member, 15 Posts

21 October 2010 at 10:26pm

Edited: 21/10/2010 10:35pm

Sorry to bump an old post, but did you ever solve this dendeffe?

Avatar
dendeffe

Community Member, 135 Posts

21 October 2010 at 11:04pm

Hi meganub,

wow, project from some way back. The code changed a few times on that. I ended up with this: http://www.sspaste.com/paste/show/4cc011bd8ec8c

The onAfterWrtite() links it to the right group.