jeudi 17 décembre 2015

CakePHP Checkbox Selecting the row

I'm trying to make a checkbox select the table row. and pass it to another controler. but it is passing only 1 checked box.

In my View.ctp

<table>
    <thead>
        <th>ID</th>
        <th>Name</th>
        <th>Action</th>
        <th>select</th>
    </thead>
    <?= $this->Form->create('test', ['id' => 'test' , 'method'=>'POST', 'url'=>'/encomendas/fastadd']) ?>
    <?php foreach ($items as $item): ?>
        <tr>
            <td><?= h($item->id) ?></td>
            <td><?= h($item->name) ?></td>
            <td><?= h($item->action) ?></td>
            <td>
            <?= $this->Form->checkbox('select', ['value' => '1']);?>
            <?= $this->Form->hidden('id', ['default' => $item->id]);?>

            </td>
        </tr>
    <?php endforeach; ?>
    <?= $this->Form->button('send') ?>
    <?= $this->Form->end(); ?>
</table>

And in

debug($this->request->data());

it returns only 1 value.




Aucun commentaire:

Enregistrer un commentaire