Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Nested DataObjects and summary fields

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 592 Views
  • VRoxane
    Avatar
    Community Member
    42 Posts

    Nested DataObjects and summary fields Link to this post

    Hello everyone !

    I have a class Commande extending ModelAdmin.
    In Commande exists a nested DataObject called NumeroColis (1 field : 'Numero'). I'm using the wonderful DOManager to handle it and it's perfect.

    BUT :

    When clicking the "Search" button, to show all the existing Commandes, I'd like to add a column called Numeros and for each Commande, show a list of the recorded NumeroColis.

    This is what I did in Commande.php :

    public function getListeNumeros() {
          $rawlist = DataObject::get('NumeroColis','CommandeID = '.$this->ID);
          $nums = $rawlist->column('Numero');
          $liste = implode(', ', $nums);
          if (isset($liste)) {
             return $liste;
          } else {
             return "Pas de colis";
          }
    }

    static $summary_fields = array(
    ...
    'ListeNumeros' => 'Numéros',
    ...
    );

    I get a Internal Server Error when clicking the Search button... and I spent a lot of time on this, so I decided to ask the great SStripe international community ! Anyone ?

  • VRoxane
    Avatar
    Community Member
    42 Posts

    Re: Nested DataObjects and summary fields Link to this post

    Thanks to the messages answering my tweet, I got a little further in my search :

    Writing

    exit($liste);

    instead of

    return $liste;

    actually shows me the list of the Colis for my first Commande.

    The Firebug Console is not helping, for it just says NetworkError : Internal Error 500 in mysite/admin/.../SearchForm

    Maybe there's something to reset between two iterations ?

  • VRoxane
    Avatar
    Community Member
    42 Posts

    Re: Nested DataObjects and summary fields Link to this post

    Update : Enabling error logging in htaccess brought me this information
    (thanks simon !)

    Fatal error: Call to a member function column() on a non-object

    592 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.