Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Automatic Refresh of has_many in ModelAdmin (HasManyComplexTableField?)

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 620 Views
  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Automatic Refresh of has_many in ModelAdmin (HasManyComplexTableField?) Link to this post

    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',
       );
    }

    620 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.