Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Customising the CMS
SilverStripe Forums » Customising the CMS » many many relationship and ModelAdmin
|
Page:
1
|
Go to End | |
| Author | Topic: many many relationship and ModelAdmin | 871 Views |
-
many many relationship and ModelAdmin

24 December 2008 at 10:32pm Last edited: 24 December 2008 10:34pm
Hi,
I've just install SilverStripe 2.3 RC2 and I'm trying the real interesting new feature : ModelAdmin
It work real properly with one to many relationship but doesn't work with many_many.
Here are my classes :
final class Book extends DataObject
{
static $db = array(
'Label' => 'Varchar',
'ISBN' => 'Varchar',
);
static $has_one = array(
'author' => 'Author'
);
static $searchable_fields = array(
'Label',
'ISBN',
);
static $summary_fields = array(
'Label',
'ISBN',
'author'
);
static $belongs_many_many = array(
'categories' => 'Category',
);
}
final class Category extends DataObject
{
static $db = array(
'label' => 'Varchar',
);static $many_many = array(
'books' => 'Book',
);
}Here is the code for model admins :
class BookAdmin extends ModelAdmin
{protected static $managed_models = array(
'Book'
);static $url_segment = 'books';
static $menu_title = 'Admin books';}
class CategoryAdmin extends ModelAdmin
{protected static $managed_models = array(
'Category'
);static $url_segment = 'categories';
static $menu_title = 'Admin categories';}
When I've build my db and flush everything I can see Category tab on Book's edit view, but can't add categories on it.
Is something wrong with my code? -
Re: many many relationship and ModelAdmin

29 December 2008 at 10:29pm
Thanks all for your aswers, such a reactive community!
-
Re: many many relationship and ModelAdmin

30 December 2008 at 5:02am
Well, sheesh... you asked a question during the biggest vacation week of the year.
I'm just barely getting my feet wet with the ModelAdmin. I love the idea, but it seems like there's a lot of room for refinement. It wouldn't surprise me if handling complex relationships like many-to-many is something that's just out of its reach right now. I'm actually not sure it will even be included with the official 2.3 release.
My suggestion would be to just go back to using a CTF like the old days.
-
Re: many many relationship and ModelAdmin

30 December 2008 at 5:51am
Hello,
thanks for your aswer but I saw in 2.3 changelog : ModelAdmin
I've download the 2.3 RC (Release Candidate means that all new features are allready implemented...)
So I think I'll look back to symfony for complex models.
See you latter!
-
many many relationship and ModelAdmin: Not that easy

13 April 2009 at 9:28pm Last edited: 14 April 2009 12:25am
Hey Everyone,
I'm in the same situation as Jean-Phi is/was and am encountering the very same problems.
I'm quite sure that this is a bug and I (and Jean-Phi) have worked properly. Even the sample code from the german SilverStripe Book does not work properly there (I refer to the Developer <-> Skills Relationship).
Hopefully, they'll get that fixed, though I've not yet found a corresponding entry in the Trac System. The only way to get it (more or less) working at the moment is to explicitely define the CMS-Fields (using getCMSFields() and ManyManyComplexTable) after that, the existing records are listed.Henning
PS: I'm using Silverstripe 2.3.1 "stable" release
-
Re: many many relationship and ModelAdmin

26 April 2009 at 10:27pm
Hey guys, I can confirm this broken behaviour. It was fixed in trunk 2 months ago, I'm hoping to get it merged to a 2.3.x minor release: http://open.silverstripe.com/ticket/3927
The fix will still only let you add new records, not associate a many_many with existing records (which you can do with ManyManyCTF), but its a start.
Particularly embarrassing as this demo code made it into the german book! Sorry for the trouble, we messed this one up - if we provide a scaffolder for certain relationship types, they should work out of the box at least in the most basic way.
| 871 Views | ||
|
Page:
1
|
Go to Top |



