我想在cakePHP的 foreach循环中的表td中创建表单,我想只在3个表 td 中构建并更新它的工作正常,但由于 td 中的形式,唯一的问题是标题的对齐。如果我从pf td中取出表格,它就无法运作
<table class="table table-hover ">
<thead>
<tr>
<th>Customer</th>
<th>Dress</th>
<th>Order Date</th>
<th>Delivery Date</th>
<th>Status</th>
<th>Tailor</th>
<th>Tailor Cost</th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($orders as $order): ?>
<tr>
<td>
<?php echo $this->Html->link($order['Customer']['name'], array('controller' => 'customers', 'action' => 'view', $order['Customer']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($order['Dress']['type'], array('controller' => 'dresses', 'action' => 'view', $order['Dress']['id'])); ?>
</td>
<td><?php echo h(date('d-M-y',strtotime($order['Order']['order_date']))); ?> </td>
<td><?php echo h(date('d-M-y',strtotime($order['Order']['delivery_date']))); ?> </td>
<td><?php echo h($status[$order['Order']['status']]); ?> </td>
**<td>
<?php echo $this->Form->create('Order',['class'=>'form-inline']); ?>
<?php echo $this->Form->input('id', ['type'=>'hidden','value'=>$order['Order']['id']]); ?>
<?php echo $this->Form->input('user_id', ['empty'=>'--Select--','options'=>$users, 'selected'=>$order['User']['id'], 'div' => false, 'label' => false, 'class' => 'form-control']); ?>
<?php echo $this->Form->input('tailor_price', ['value' =>$order['Order']['tailor_price'], 'div' => false, 'label' => false, 'class' => 'form-control','style'=>'max-width:140px;']); ?>
<?php echo $this->Form->button(__('Update'), ['class' => 'btn btn-default']) ?>
<?php echo $this->Form->end(); ?>
</td>**
</tr>
<?php endforeach; ?>
</tbody>
但它打破了桌面和td路线:
请帮帮我。先谢谢你。
答案 0 :(得分:0)
试试这个
<?php echo $this->Form->create('Order',['class'=>'form-inline']); ?>
<td>
<?php echo $this->Html->link($order['Customer']['name'], array('controller' => 'customers', 'action' => 'view', $order['Customer']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($order['Dress']['type'], array('controller' => 'dresses', 'action' => 'view', $order['Dress']['id'])); ?>
</td>
<td><?php echo h(date('d-M-y',strtotime($order['Order']['order_date']))); ?> </td>
<td><?php echo h(date('d-M-y',strtotime($order['Order']['delivery_date']))); ?> </td>
<td><?php echo h($status[$order['Order']['status']]); ?>
</td>
<td>
<?php echo $this->Form->input('id', ['type'=>'hidden','value'=>$order['Order']['id']]); ?>
<?php echo $this->Form->input('user_id', ['empty'=>'--Select--','options'=>$users, 'selected'=>$order['User']['id'], 'div' => false, 'label' => false, 'class' => 'form-control']); ?>
</td>
<td>
<?php echo $this->Form->input('tailor_price', ['value' =>$order['Order']['tailor_price'], 'div' => false, 'label' => false, 'class' => 'form-control','style'=>'max-width:140px;']); ?>
</td>
<td>
<?php echo $this->Form->button(__('Update'), ['class' => 'btn btn-default']) ?>
</td>
<?php echo $this->Form->end(); ?>
答案 1 :(得分:0)
您的th
和td
不相等th
为8,td
仅为6
(这就是你的专栏混合的原因)
<table class="table table-hover ">
<thead>
<tr>
<th>Customer</th>
<th>Dress</th>
<th>Order Date</th>
<th>Delivery Date</th>
<th>Status</th>
<th>Tailor</th>
<th>Tailor Cost</th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($orders as $order): ?>
<tr>
<?php echo $this->Form->create('Order',['class'=>'form-inline']); ?>
<td>
<?php echo $this->Html->link($order['Customer']['name'], array('controller' => 'customers', 'action' => 'view', $order['Customer']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($order['Dress']['type'], array('controller' => 'dresses', 'action' => 'view', $order['Dress']['id'])); ?>
</td>
<td><?php echo h(date('d-M-y',strtotime($order['Order']['order_date']))); ?> </td>
<td><?php echo h(date('d-M-y',strtotime($order['Order']['delivery_date']))); ?> </td>
<td><?php echo h($status[$order['Order']['status']]); ?> </td>
<td>
<?php echo $this->Form->input('id', ['type'=>'hidden','value'=>$order['Order']['id']]); ?>
<?php echo $this->Form->input('user_id', ['empty'=>'--Select--','options'=>$users, 'selected'=>$order['User']['id'], 'div' => false, 'label' => false, 'class' => 'form-control']); ?>
</td>
<td>
<?php echo $this->Form->input('tailor_price', ['value' =>$order['Order']['tailor_price'], 'div' => false, 'label' => false, 'class' => 'form-control','style'=>'max-width:140px;']); ?>
</td>
<td>
<?php echo $this->Form->button(__('Update'), ['class' => 'btn btn-default']) ?>
</td>
<?php echo $this->Form->end(); ?>
</tr>
<?php endforeach; ?>
</tbody>