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.

Data Model Questions /

onBeforeWrite calls




Community Member, 24 Posts

8 March 2013 at 10:42pm


I've extended Member object with onAfterWrite function that adds users to contacts group. Here is the code:

class MemberContact extends DataExtension {   

   static $belongs_many_many = array(
            'Companies' => 'Company'

   function onAfterWrite() {
      $group = Group::get()
                  ->filter('Code', 'contacts')

As you can notice there is many_many relation of Member with Company dataObject. My question is that it seems that onAfterWrite (or onBeforeWrite for that matter) doesn't get called when I add a member as many_many relation to Company object (through admin interface (modeladmin)). It gets called when I create new member, though. How can I achieve this? Is this feature or a bug?