7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » ManyManyDataObjectManager in ModelAdmin breaks save action
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1520 Views |
-
ManyManyDataObjectManager in ModelAdmin breaks save action

11 May 2009 at 9:59pm
Has anyone gotten the ManyManyDataObjectManager to work properly in ModelAdmin?
Currently, when I replace the default many-many relationship field with the ManyManyDataObjectManager, it stops me from being able to save changes on other fields/tabs.
i.e. if I make a change to any other field, I can't save the change(s) until I make a change on the MMDOM.
I'm using SS version 2.3.1 and DataObjectManager r137.
Some sample code:
class Company extends DataObject {
static $db = array(
'Name' => 'Varchar(200)'
);static $many_many = array(
'BusinessTypes' => 'BusinessType'
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab( 'Root.BusinessTypes', 'BusinessTypes' );
$fields->addFieldToTab( 'Root.BusinessTypes', new ManyManyDataObjectManager(
$this,
'BusinessTypes',
'BusinessType',
array( 'Name' => 'Business Type' )
));
return $fields;
}
}update
To make it a bit more confusing - saving seems to work fine is you strip out the default TabSet.
You can do this by callinginside getCMSFields().$fields->changeFieldOrder( array( 'Name', 'BusinessTypes' ) )
-
Re: ManyManyDataObjectManager in ModelAdmin breaks save action

12 May 2009 at 2:34am
I know next to nothing about ModelAdmin, but I'm very interested in the concept. I'd be interested in any input you guys have on getting DOM ModelAdmin compliant.
This sounds like a javascript error. Is DOM fighting with the Tabset, perhaps? Can you check Firebug?
-
Re: ManyManyDataObjectManager in ModelAdmin breaks save action

12 May 2009 at 9:13pm
Hi UncleCheese,
Firebug saved the day!
It was complaining that some function in jqeury (ui.core line 136) was failing. Tracked it back to a calls made in /cms/javascript/ModelAdmin.js line ~24. Just put the calls in a try-catch and everything seems to be working again.
So in other words, my /cms/javascript/ModelAdmin.js now looks like this:
// Line ~21
/**
* Attach tabs plugin to the set of search filter and edit forms
*/$('ul.tabstrip').livequery(function() {
try
{
$(this).tabs();
$(this).tabs({
// This show handler is necessary to get tabs working properly with the crappy old layout_helpers.js layout
// manager
show : function() {
if(window.onresize) window.onresize();
}
});
}
catch(err)
{
// do nothing?
}
});Hope that helps somebody
| 1520 Views | ||
|
Page:
1
|
Go to Top |

