好,我發現我的解決方案,所以我會爲任何人有這個分享問題
我在控制器中的動作:
$modalView = $this->renderPartial('ingredients-modal-content.twig');
$this->view->params['modalView'] = $modalView;
//and another action codes like rendering mainview and etc
,所以我們可以做任何我們想做的與樹枝和我們的觀點,即iniside ingridients模態,content.twig或發送PARAMS給它..
在
ingridients模態-content.twig:
在我們的main.php
<form action="/cars/add-cars" method="post" class="form-group" id="repairmen">
<div class="col-md-4 pull-right" style ="padding:0px; " >
<input type="submit" id="repairmen" class="btn btn-success" style="width:100%;" value = "Add"></input>
</div>
<div class="col-md-4 pull-right" style ="padding:0px;" >
<input type="text" class="form-control" id="repairmen_name" placeholder="ID" style = "text-align:center;" name="product_id" >
</div>
<div class="col-md-4 pull-right" style ="padding:0px;" >
<input type="text" class="form-control" id="repairmen_name" placeholder="Name" style = "text-align:center;" name="product_name" >
</div>
</form>
<table class="table" style="
direction: rtl;
text-align: right !important;
">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{item.ID}}</td>
<td>{{item.Name}}</td>
<td>{{item.Price}}</td>
</tr>
</tbody>
</table>
<button type="button" class="btn btn-success" data-dismiss="modal" style="width:100%">submit</button>
下一個(或其他佈局文件)
<?php
Modal::begin([
'header' => '<h4>title</h4>',
'id' => 'model',
'size' => 'model-lg',
]);
if (isset($this->params['modalView'])){
echo $this->params['modalView'];
}; Modal::end();
?>
,並在我們的MAINVIEW開放模式將在main.php呈現在<?= $content ?>
在按鈕只是這樣做:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#model">
button name</button>
就是這樣