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: http://doc.silverstripe.org/doku.php?id=member#extending_member_or_dataobject.
Members will have a many_many relation with a committees table.
<?php
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(
'Resident',
'Committee'
);
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.