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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Nested DataObjects and summary fields


Reply

3 Posts   626 Views

Avatar
VRoxane

5 February 2012 at 10:07am (Last edited: 5 February 2012 10:08am), Community Member, 42 Posts

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 ?

Avatar
VRoxane

2 April 2012 at 1:27am (Last edited: 2 April 2012 1:27am), Community Member, 42 Posts

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 ?

Avatar
VRoxane

2 April 2012 at 3:41am Community Member, 42 Posts

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

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