So I have view where at an array of database records are passed in to the as below
controller.php
public function actionPackage_list() {
$this->checkLoginAgent();
$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);
}
view.php
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>
</div>
</div>
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