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, simon_w

ModelAdmin manymany


Reply


2 Posts   1375 Views

Avatar
dendeffe

Community Member, 135 Posts

17 February 2010 at 1:20pm

Hi,

I have a Designer object with a many_many connection to Regions. I edit them throught the ModelAdmin.

I have rebuilt the Regions tab for a designer with this code I found on the forum

   public function getCMSFields()
      {
         $f = parent::getCMSFields();
         // rebuild the regions tab
         $f->removeByName('Regions');
         $regionsTablefield = new ManyManyComplexTableField(
            $this,
            'Regions',
            'Region',
            array('Title' => 'Title')
         );
         $regionsTablefield->setAddTitle('Regions');
         $regionsTablefield->setPageSize('50');
         $f->addFieldToTab('Root.Regions', $regionsTablefield);
         
         return $f;
      }

This works, but only when I have done the following:

1/ Saved the Designer object and then
2/ Reloaded the designers list by pressing the tab at the top fo the ModelAdmin and
3/ Reopened my Designer object

When I try to add Regions when I first create the Designer, the Regions aren't saved. When I simply open the Designer without refreshing the list (step 2), it won't save anymore, the loading animation on the button will keep running.

Avatar
dendeffe

Community Member, 135 Posts

16 March 2010 at 12:40am

I'm still looking in to this.

I have found out more:

1/ It only happens when a HTMLEditorField is added. I tried copying the modified ModelAdmin.js from this: http://open.silverstripe.org/browser/modules/cms/trunk/javascript/ModelAdmin.js?rev=79352 But that didn't work.

2/ When I try to save a many_many relationship, I get this error: t.win.document is null, which is something to do with TinyMCE.

3/ If I try to edit after the first save, these files don't seem to want to load (although they are available):

http://conceptsverde.local/jsparty/tiny_mce2/themes/advanced/skins/default/content.css?m=1238116563
http://conceptsverde.local/jsparty/tiny_mce2/plugins/spellchecker/css/content.css?m=1238116563
http://conceptsverde.local/jsparty/tiny_mce2/plugins/media/css/content.css?m=1238116563
http://conceptsverde.local/cms/css/editor.css?m=1238116563
http://conceptsverde.local/themes/conceptsverde/css/editor.css?m=1238116563