Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » ModelAdmin (add member to group)

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

Page: 1
Go to End
Author Topic: 2106 Views
  • dendeffe
    Avatar
    Community Member
    135 Posts

    ModelAdmin (add member to group) Link to this post

    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?

  • teejay
    Avatar
    Community Member
    63 Posts

    Re: ModelAdmin (add member to group) Link to this post

    Hi dendeffe,

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

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: ModelAdmin (add member to group) Link to this post

    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.

  • teejay
    Avatar
    Community Member
    63 Posts

    Re: ModelAdmin (add member to group) Link to this post

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

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: ModelAdmin (add member to group) Link to this post

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

  • meganub
    Avatar
    Community Member
    15 Posts

    Re: ModelAdmin (add member to group) Link to this post

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

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: ModelAdmin (add member to group) Link to this post

    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.

    2106 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.