0
내가하려는 것은 사용자가 인벤토리에서 여러 제품을 체크 아웃 할 수있는 방법을 제공하는 것이다.Cakephp 체크 박스 배열을 다른 컨트롤러에 전달
내 제품 인덱스 페이지 (목록 사용 가능한 모든 제품을 체크 아웃 할)은 다음과 같습니다
내가 여러 항목을 체크 아웃 할 수있는 새로운 기능을 추가 한 내 체크 아웃 컨트롤러에서 다음<?php echo $this->Form->create('multi');?>
<?php foreach ($products as $product): ?>
<tr class="hovertable">
//All the fields go here
<td style="cursor: default">
<?php echo $this->Html->link($this->Html->image('tr/Checkouts_Add.png') . " " . __('Checkout'), array('controller' => 'Checkouts','action' => 'add', $product['Product']['id']), array('escape' => false, 'class' => 'button')); ?>
<?php echo $this->Html->link($this->Html->image('tr/Edit.png'), array('action' => 'edit', $product['Product']['id']), array('escape' => false)); ?>
<?php echo $this->Form->postLink($this->Html->image('tr/Delete.png'), array('action' => 'delete', $product['Product']['id']), array('escape' => false), __('Are you sure you want to delete # %s?', $product['Product']['id'])); ?>
<?php echo $this->Form->input('Product.id.'.$product['Product']['id'] ,
array('label' => false,
'type' => 'checkbox',
'id'=>'listing_'.$product['Product']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
<?php echo $this->Form->submit(__('Submit'));?>
, 내가 좋아하는 것 이 양식은 확인 된 제품
public function multi($count = 1) {
if($this->request->is('post')) {
foreach($this->request->data['Checkout'] as $data) {
//Do not forget this line. you need to create new model for saving each time.
if ($this->request->isPost()) {
$this->Checkout->create();
$this->Checkout->save($data);
} else {
$this->request->data['Checkout']['product_id'] = $productId;
}
}
$this->redirect(array('action' => 'index'));
}
$products = $this->Checkout->Product->find('list');
$users = $this->Checkout->User->find('list');
$this->set(compact('products', 'users'));
$this->set('count', $count);
}
당신은 내가 일을하지만 아무것도하지 않는 제품 인덱스 페이지에서 제출 버튼을 거라고 생각 모자를 추가하려고했습니다시피
에 의해 채워 져야합니다. 어떤 도움이라도 대단히 감사하겠습니다!