I'd like to manage different filtered lists of the same DataObject in ModelAdmin. I have the DataObject "Message" which has a SentbyID and a SenttoID. In ModelAdmin I want to manage two lists. One list with all messages with a certain SentbyID and one list with messages with a certain SenttoID. Can I manage this two lists in different tabs, f.e. "Inbox" and "Outbox"? How can I do this?
I have this so far:
class MessageAdmin extends ModelAdmin {
private static $menu_title = 'Messages';
private static $url_segment = 'messages';
private static $managed_models = array (
'Message'
);
public function getList() {
$currMember = Member::currentUserID();
$list = Message::get()->filter(array('SenttoID' => $currMember));
return $list;
}
}
Overload getEditForm and define a new FieldList containing a TabSet. The SilverStripe Comments module provides a great example this in action, by showing different types of comments (Spam vs. Moderated) in separate tabs within the same ModelAdmin.
Have a look at https://github.com/silverstripe/silverstripe-comments/blob/2.1/code/admin/CommentAdmin.php