如何在PHP中使用phalcon变量?

信息素

我在内创建了一个变量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&eacute;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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章