我在内创建了一个变量controller
:
<?php
use Phalcon\Mvc\Controller;
class RestaurantreservationController extends Controller
{
public function indexAction(){
return $this->view->pick("reservation/listerReservation");
}
public function affecterReservTableAction($id) {
$this->view->action_form = 'affecterReservTableExec';
$this->view->titre = 'Réservation de table';
$this->view->table_code = $id; // here is the variable I want to manipulate
return $this->view->pick("reservation/reservTable");
}
}
?>
在视图内部,reservTable.phtml
我想使用变量table_code
:
<div class="input-control select">
<select name="clt_id" id="clt_id">
<option value="">--Choisir une table--</option>
<?php
$table_code = {{table_code}}; // it generates an error
$tables = TableClient::lireParCritere([]);
foreach ($tables as $table) {
$select = ($table_code == $table->table_code ? "selected" : "" );
?>
<option <?php echo $select; ?> value="<?php echo $table->table_code; ?>"><?php echo $table->noms; ?></option>
<?php
}
?>
</select>
</div>
如何使用它将其设置为元素的选定select
元素?
问题是当您尝试分配{{table_code}}
给时,您正在混合使用phtml和Volt语法$table_code
。
Volt变量{{ table_code }}
与相同$table_code
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句