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, Ed, biapar, Willr, Ingo, swaiba

extending member / ModelAdmin

Go to End



Community Member, 26 Posts

12 April 2010 at 4:17am

Edited: 12/04/2010 4:34am

Bit of a long post - please bear with me.

I have a site (non-profit co-op housing) where I'm going to have a single member type called Resident. All members in the system will need login ability so I've gone the route of extending member rather than decorating it as per the recommendation in the following link:

Members will have a many_many relation with a committees table.


class Resident extends Member {
    static $db = array(
       //extra member fields...
    static $many_many = array(
        'Committees' => 'Committee'

and the committees do:

class Committee extends DataObject {
    static $db = array(
        'Name' => 'Varchar(30)',
    static $belongs_many_many = array(
        'Residents' => 'Resident',

I've also added a line in _config.php to use the resident class instead of member (not sure about this though):

Object::useCustomClass("Member", "Resident");

I rebuild and all appears well. There is the resident table, and the join table resident_committees.

I then created a model admin interface to manage the members:

class CoopAdmin extends ModelAdmin {
    static $managed_models = array(
    static $url_segment = 'coop';

This interface loads but the functionality doesn't seem very practical at this point.

I have added a 'Membership' category to test (screenshot41.jpg).

I want to attach a Resident to the Membership committee I've just created, but cannot do it via the admin interface. When I try to edit a member and click on the committee tab, the committee shown above does not appear. I can add a new committee (screenshot42.jpg), even using the same name as the committee that is already in the committee table (duplicateentrymysql.jpg).

What I need is an interface like the one available for groups (screenshot43.jpg).

The desired interface would lists available committees and allows me to select which ones the Resident belongs to.

Any help on how to achieve this result is very much appreciated.