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.

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.

Data Model Questions /

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

How to limit user selection in ManyManyComplexTableFiled


Go to End


1758 Views

Avatar
Ben_W

Community Member, 80 Posts

3 June 2011 at 5:16pm

I have the following ManyManyComplexTableField, which basically form a many to many relationship that allows user to pick number of pages as recommended reading for a given page. Is there a way I can enforce a business rule into this, say user may not select more than 5 pages as recommended reading. Need a way to disable the checkbox I would thought. Any pointer would be deeply appreciated. Cheers.

$tablefield = new ManyManyComplexTableField(
	$this,
	'MyRegionPages',
	'Page',
	array(
		'Title' => 'Page Name',
		'BoldIntroduction' => 'Bold Introduction'
	),
	'getCMSFields_forPopup',
	 "SiteTree.ID != $this->ID AND SiteTree.ParentID=$this->ParentID",
	 'Sort'
);

$tablefield->setPermissions(array(
));


$fields->addFieldToTab( 'Root.Content.FurtherReadings', $tablefield );