多个提交按钮以在cakephp 3.x的索引页面中提交表单

时间:2018-07-10 17:40:05

标签: jquery cakephp cakephp-3.0

我有index.ctp页面,其中每一行都有提交按钮,我必须提交表单。但是,在提交表单时,最后一行ID总是在行,该ID应该是每行明智的。

我已经提到了以下代码。现在,这里正在提交表单,但供应商总是使用一个ID,它不会按行更新。我必须在哪里进行修改以通过提交表单将供应商发送给行?

   <?= $this->Form->create($prSuppliers, ['id'=>'createform','url' => ['action' => 'sendinquiry']]); ?>        
  <table id="example2" class="products_table table table-bordered table-hover">
   <?php foreach ($prSuppliers as $CompanyKey=>$CompanyVal){ ?>
            <tr class='tableRow'>
           <td>
            <?php
            echo $this->Form->input('supplier',array('type'=>'hidden','value'=> $CompanyVal->company_master_id));
            $options = array
            (
                    'value' => $CompanyVal->company_master_id,
                    'id' => 'submitButton',
                    'div' => false,
                    'class'=>'submitButton btn btn-success'
            );
            echo  $this->Form->button('Create Inquiry',$options);

            ?>              
           </td>
           </tr>

   <?php }?>
  </table>
   <?= $this->Form->end() ?>

  <script>
    $(document).ready(function() {
   $(".tableRow").each(function(){
        var _this=$(this);

        $(_this).find(".submitButton").click(function(){
            var supplier=$(_this).find(".supplier").val();
            $(_this).find(".supplier").val(supplier);
            $("form").submit();         
            //return false;
        });

    }); 


    }); 
</script>

0 个答案:

没有答案