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.

General Questions

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

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

ModelAdmin (add member to group)


7 Posts   2162 Views


10 February 2010 at 2:56pm Community Member, 135 Posts

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?


11 February 2010 at 12:16pm Community Member, 63 Posts

Hi dendeffe,

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



11 February 2010 at 1:48pm Community Member, 135 Posts

Hi Teejay,

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

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.


11 February 2010 at 2:25pm Community Member, 63 Posts

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 ??


11 February 2010 at 10:23pm Community Member, 135 Posts

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


21 October 2010 at 10:26pm (Last edited: 21 October 2010 10:35pm), Community Member, 15 Posts

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


21 October 2010 at 11:04pm Community Member, 135 Posts

Hi meganub,

wow, project from some way back. The code changed a few times on that. I ended up with this:

The onAfterWrtite() links it to the right group.