Jump to:

22979 Posts in 11808 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Trouble managing Many Many on Member [RESOLVED]

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: 315 Views
  • Lazarus404
    Avatar
    Community Member
    71 Posts

    Trouble managing Many Many on Member [RESOLVED] Link to this post

    Hi guys,

    I'm having some trouble managing a many_many relationship on the Member class.

    So, I've created a decorator that appends Member with project developments. Like this

    class ClientDecorator extends DataObjectDecorator
    {
       function extraStatics() {
          return array(
             'many_many'   =>   array(
                'Developments'         =>   'Development'
             )
          );
       }
       
       public function updateCMSFields(FieldSet $fields) {
          $fields->addFieldToTab('Root.Members', new CheckboxField('RedirectToConveyancing', 'Redirect to Conveyancing on Login'));
          $devs = DataObject::get('Development')->map('ID','Name');
          $devfield = new ManyManyComplexTableField(
    $this->owner,
    'Developments',
    'Development',
    array(
    'Name' => 'Name'
    ),
    'getCMSFields_forPopup'
    );
          $fields->addFieldToTab('Root.Developments', $devfield);
       }
    }

    When I edit a Member under Security in the admin, the box shows and lists the developments, complete with those assigned to the member, but when I change the developments assigned to the member and save, it doesn't store the changes. Am I doing something wrong?

    Thanks,
    Lee

  • Lazarus404
    Avatar
    Community Member
    71 Posts

    Re: Trouble managing Many Many on Member [RESOLVED] Link to this post

    Anyone? It's still an issue and I can't find how to resolve it.

    Thanks.

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Trouble managing Many Many on Member [RESOLVED] Link to this post

    No idea, but my advice would be to find a module like member profiles that might do something similar and copy that.

  • Lazarus404
    Avatar
    Community Member
    71 Posts

    Re: Trouble managing Many Many on Member [RESOLVED] Link to this post

    Thanks Swaiba.

    I've actually figured it out turns out to the the whole "ManyManyComplexTableField not saving in a popup" bug. I fixed it by adding some code to a onBeforeWrite handler.

    Thanks again.

    Lee

    315 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.