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

many_many relationship - delete row in tablelistfield


Go to End


2 Posts   2185 Views

Avatar
ib

Community Member, 2 Posts

31 March 2010 at 5:16pm

Hi!

I would like to organise persons and countries, which are both DataObjects, with modeladmin. One person is eligible to work in many countries and countries relate to many persons eligible to work in it.

In the CMS I add eligibility countries with a dropdownfield in person class getCMSFields() to the many_many relation.

To list all countries a person is eligible to work with tablelistfield in the CMS works fine. But my problem is to delete a row in the table. I tried to delete rows in the tablelistfield with the delete permission. Unfortunately the country object will be deleted and not just the relation between person and country.

Does anybody know how to delete just the relation with a button or link in the tablelistfield??

Thx,
ib

Avatar
baba-papa

Community Member, 279 Posts

1 April 2010 at 2:29am

With the method getCMSFields_forPopup() you can define how your popup field for a single entry in the ComplexTableField looks like. I would display the country as a CheckboxSetField.
This tutorial can help: http://doc.silverstripe.org/doku.php?id=tutorial:5-dataobject-relationship-management&s=getcmsfields%20forpopup