Define class at widget configuration

Hi!

I was wondering if is possible to make something like this:


$this->widget('Graphic', array(

	'name' => 'My graphic',

	'lines' => array(

		'line1' => array(

			'class' => 'Line',

			'values' => array(

				1 => 123,

				2 => 321,

			),

		),

	),

));

That is, the widget have a attribute that contains a array of Line objects, and the Line Objects have the values attribute. Can I define it in a configuration array like the shown?

Thanks in advance.

You’ll need something like this:




class Graphic extends CWidget

{




	private $_lines = array();




	public function setLines(array $lines)

	{

		foreach ($lines as $index => $line) {

			$this->_lines[$index] = Yii::createComponent($line);

		}

	}

}



It worked. Thanks a lot.