Display HAS_MANY relation in cDetailView

Hi, i want to display all "Artikels" belonging to my "Buch" in a cDetailView.

Sadly my values appear outside of the table. Don´t know how to fix this.

Please help.

Here is what i got:


public function relations()


		return array(

			'artikels' => array(self::HAS_MANY, 'Artikel', 'buchId'),



and in my models/Artikel.php

public function relations()


		return array(

			'buch' => array(self::BELONGS_TO, 'Buch', 'id'),



Now the part that doesn´t work (although I get the list with all Artikels, but outside of the cDetailView):

<?php $this->widget('zii.widgets.CDetailView', array(












			//'value'=>CHtml::listData(Artikel::model()->findAll(), 'id', 'name'),



)); ?>

and here my function getRelatedArtikel in models/Buch.php:

public function getRelatedArtikel ()



	   $ausgabe = '<ul>';

	   foreach($out as $key=>$value) { 

		$ausgabe .= printf('<li>%s</li>', CHtml::link($value, array('artikel/view', 'id' => $key)));



	   $ausgabe .= '</ul>';

	   return $ausgabe;


Note: you should have <li> elements inside your <ul> element.

It was in my code before. Edited my post above. But problem still exists with the correct HTML.

You should use sprintf instead of printf.


You have a very good eye, Tommy :)

Thank you very much. That worked. Topic closed.