Need help with onclick events

So I have view where at an array of database records are passed in to the as below


public function actionPackage_list() {


		$model = Packageinfo::model();

		$packagesArr = $model->findAll();

		$packages = Array();

		foreach ($packagesArr As $v) {

			$packages[] = array


				"id" => $v-> pkg_id,

				"pkg_name" => $v-> pkg_name,

			        "pkg_price" => $v-> pkg_price,

				"details" => $v-> details,

				"currency" => $v-> currency



		$data = array(

			"packages" => $packages,


		$this->render("package_list", $data);



div class="product_info">

  <?php foreach ($packages as $package) { ?>

<p><?php echo $package["pkg_name"]; ?></p>

					<div class="price">

						<div class="price_2">

							<span class="curr"><?php echo $package["currency"]; ?></span>

							<span class="price_3"><?php echo $package["pkg_price"]; ?></span>



In the view the records are printed into the html except for the details part. Instead I want it to have a button for each record. When clicked it will display details part of the record in a separate div section.

How can i achieve this with the yii framework? Perhaps CHtml::button() or CHtml::AjaxButton?

Also I am trying to wrap my head conceptually how to achieve this perhaps some code snippets would be helpful. I was also thinking maybe i can pass the trigger an event back to the controller to filter out the data model and send back the appropriate database array item back to the view

Okay so i moved my code into netbeans and installed xdebug so i have a better insight of whats going on so perhaps i can narrow down my question more. So I was able to trigger an ajax call into the controller but how do i pass data back into controller from the view?

initially my database is queried and the data is passed into the view as an array when it is rendered, but now i want to take say an attribute "package_details"" from the array and have the that string accepted by the controller, do somethibg with it and echo it back out.