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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Select existing member instead of creating new (modeladmin)


Go to End


5 Posts   767 Views

Avatar
esakrielaart

Community Member, 59 Posts

3 January 2012 at 6:05am

Hello all,

I have the following relationship

Class A <--- many_many ---> Member

and it is moderated using the ModelAdmin interface. Now when I create a new Class A object, I wish to select from the new tab 'Member' -> 'Add new Member' an existing Member from a dropdown or similar fashion. However, it shows the form to create a new member. How can I modify this behavior? I suggest I need to change getCMSFields_forPopup() function somewhere?

Any help is highly appreceated.

Friendly regards,
Maurice

Avatar
swaiba

Forum Moderator, 1899 Posts

3 January 2012 at 10:35pm

Avatar
esakrielaart

Community Member, 59 Posts

4 January 2012 at 4:03am

Thank you, that is a good start for me. Now I only still do not completely seem to get how to override the save/delete methods from the ComplexTableField. I know I have to override it, so I tried to create a new class:

class SpecialComplexTableField extends ComplexTableField {

}
class SpecialComplexTableField_Popup extends ComplexTableField_Popup {
  function saveComplexTableFields() {
    die("Notice I am here");
  }
}

However I seem to be wrong. What am I doing wrong? Because without changing this, when I delete a row from the CTF, it also deletes the associated Member info!

Thanks in advance,
Maurice

Avatar
swaiba

Forum Moderator, 1899 Posts

4 January 2012 at 4:10am

how to override the save/delete methods from the ComplexTableField

It's not something that is overridden, but you can "hook" into it...

http://doc.silverstripe.org/sapphire/en/topics/datamodel#onbeforewrite

Avatar
esakrielaart

Community Member, 59 Posts

4 January 2012 at 4:24am

Ah thank you, it is coming together now (trying to understand to deeper workings of silverstripe). Really enjoy it and thank you for the support.

Friendly regards,
Maurice