0

我正在使用 Yii2-advanced-template。我的表单上有 2 个部分,如下所示 -两个 <div> 标签当我单击第 2 个 div 中的任何单选按钮时,相应条目的详细信息应加载到第 1 个 div 中。也就是说,第一个 div 中的表单将保持原样,但会加载一些值以进行更新操作。但我得到它 -布局问题这不是我所期望的。它正在该 div 中加载整个页面布局。

我已经在控制器中使用了“renderPartial()”。但它只解决了一半的问题,即使用 renderPartial() 后导航栏和其他布局被隐藏。

我的表格如下-

<div class="col-sm-12">
    <div class="col-sm-6 fillitemform">
        ...
        Enter Item Details form
        ...
    </div>
<div id="item_details" class="col-sm-6">
  <div class="panel panel-primary">
    <div class="panel-heading">
      <h3 class="panel-title">Item details</h3>
    </div>
    <div class="panel-body">
      <div class="table-responsive" >
       <table class="table">
         <thead>
         <tr><th></th>
             <th>PO No.</th>
             <th>SKU</th>
             <th>Order Type</th>
             <th>Expected Qty</th>
             <th>Received Qty</th>
             <th>Weight</th>
           </tr>
         </thead>
         <tbody>
         <?php
          for($itr = 0, $ro = $modelRO, $rod = $modelROD; $itr < count($modelROD); ++$itr){
            echo '<tr onclick="placeitemdtls('.$rod[$itr]['id'].')">';
            echo '<td><input type="radio" name="item"></td>';
            echo '<td>'.$ro[0]['ro_po_no'].'</td>';
            echo '<td>'.$rod[$itr]['rod_sku'].'</td>';
            echo '<td>'.$ro[0]['ro_order_type_id'].'</td>';
            echo '<td>'.$rod[$itr]['rod_expected_qty'].'</td>';
            echo '<td>'.$rod[$itr]['rod_received_qty'].'</td>';
            echo '<td>'.$rod[$itr]['rod_weight'].'</td>';
            echo '</tr>';
          }
         ?>
       </tbody>
     </table>
   </div>
 </div>
</div>
</div>
</div>

我的 JS/jQuery 函数-

function placeitemdtls(id){
  $.post("index.php?r=receiving-order-details/update&id="+id, function(response) {
    jQuery(".fillitemform").html(response);
  });
}

我的控制器功能-

public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $modelRO = ReceivingOrders::find()->where(['id' => $id])->all();
        $modelROD = ReceivingOrderDetails::find()->where(['receiving_order_id' => $id])->all();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['create', 'id' => $id]);
        } else {
            return $this->renderPartial('update', [
                'model' => $model, 'modelRO' => $modelRO, 'modelROD' => $modelROD,
                ]);
        }
    }

请注意,我得到了具有正确值的正确表单,但是如我在第二张图像中所示的那样存在渲染问题。请帮我解决它。所以我的输出应该看起来像 -预期产出

4

0 回答 0