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 /

Automatic Refresh of has_many in ModelAdmin (HasManyComplexTableField?)


Reply


776 Views

Avatar
swaiba

Forum Moderator, 1808 Posts

14 December 2010 at 1:31am

Suppose I have the code below... when I add 'ObjectWithOne' to 'ObjectWithMany' using ModelAdmin the new item doesn't appear in the this list. I need to hit search again, then re-select the 'ObjectWithMany' i created the 'ObjectWithOne' for. This also is an issue when I edit one of the items - it doesn't update the list upon closing the popup...

...is there anything someone can help me with to get this fixed please?

<?php

class HasManyAdmin extends ModelAdmin
{
   static $managed_models = array(
      'ObjectWithMany',
   );

   static $url_segment = 'hasmanyadmin';
   static $menu_title = 'HasManyAdmin';
}

class ObjectWithMany extends DataObject
{
   static $db = array(
      'Name' => 'Text',
   );

   static $has_many = array(
      'ObjectWithOne' => 'ObjectWithOne',
   );
}

class ObjectWithOne extends DataObject
{
   static $db = array(
      'Name' => 'Text',
   );

   static $has_one = array(
      'ObjectWithMany' => 'ObjectWithMany',
   );
}