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

Trouble managing Many Many on Member [RESOLVED]


Go to End
Reply


4 Posts   487 Views

Avatar
Lazarus404

Community Member, 71 Posts

30 March 2012 at 5:01pm

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

Avatar
Lazarus404

Community Member, 71 Posts

5 April 2012 at 10:59am

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

Thanks.

Avatar
swaiba

Forum Moderator, 1824 Posts

5 April 2012 at 11:18am

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

Avatar
Lazarus404

Community Member, 71 Posts

5 April 2012 at 11:58am

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