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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Nested DataObjects and summary fields


Go to End


3 Posts   1673 Views

Avatar
VRoxane

Community Member, 42 Posts

5 February 2012 at 10:07am

Edited: 05/02/2012 10:08am

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

Community Member, 42 Posts

2 April 2012 at 1:27am

Edited: 02/04/2012 1:27am

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

Community Member, 42 Posts

2 April 2012 at 3:41am

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

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