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?
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.
Hi dendeffe,
could u pls post abit more code so that this a bit more transparent ?
:)
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.
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 ??
Hmmm I haven't edited group, because it's a Class in Sapphire itself
Sorry to bump an old post, but did you ever solve this dendeffe?
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.