CRUD - send id of selected line to Toolbar - Cakephp

Asked

Viewed 138 times

3

I’ve been hitting myself for a while with the following problem:

I set up a CRUD on Cakephp, I did the grid with css to be cool and ready. The problem is that it is not at all elegant to have an action column and the buttons "View", "Add", "Promote" and "Refuse" appear on all lines in this column. So I created a nice Toolbar and I get to my problem, I can’t pass the value of the line id to the Toolbar link using checkbox or radio. Below is the html of the table, I await a help.

inserir a descrição da imagem aqui

<table class="tabela-crud">
    <thead>
        <tr>
            <TH colspan="9">Solicitação de Produtos</TH>
        </tr>
        <tr>
            <th colspan="9" style='text-align: left;'>
               <?php echo $this->Html->link( "Visualizar", array('action'=>'view'), array('class' => 'btn-crud') ); ?>
               <?php echo $this->Html->link( "Editar", array('action'=>'edit'), array('class' => 'btn-crud') ); ?>
               <?php echo $this->Html->link( "Nova", array('action'=>'add'), array('class' => 'btn-crud') ); ?>                
            </th>

        </tr>   
    </thead>  
    <tbody>
        <tr>
            <th style='width: 1px;'>            
            </th>
            <th ><?php echo $this->Paginator->sort('id', 'ID');?>  </th>
            <th><?php echo $this->Paginator->sort('codigo_produto', 'Código');?>  </th>
            <th><?php echo $this->Paginator->sort('codigo_pedido', 'Pedido');?></th>
            <th><?php echo $this->Paginator->sort('data_pedido', 'Emissão Pedido');?></th>              
        </tr>
        <?php $count=0; ?>
        <?php foreach($produtos as $produto): ?>                
        <?php $count ++;?>
        <?php if($count % 2): echo '<tr>'; else: echo '<tr class="zebra">' ?>
        <?php endif; ?>
    <td style="text-align: center;">
        <input type='radio' id='r-<?php echo $produto['Produto']['id']; ?>'name='id-radio' value='<?php echo $produto['Produto']['id']; ?>'>
    </td>
        <td style="text-align: center;"><?php echo $produto['Produto']['id']; ?></td>
        <td style="text-align: center;"><?php echo $produto['Produto']['codigo_produto'];?></td>
        <td style="text-align: center;"><?php if($produto['Produto']['codigo_pedido'] === null){echo ' - ';}else{ echo $produto['Produto']['codigo_pedido']; } ?></td>
        <td style="text-align: center;"><?php if($produto['Produto']['data_pedido']  === null){echo ' - ';}else{ echo $produto['Produto']['data_pedido']; }?></td>
    </tr>               
    <?php endforeach; ?>
    <?php unset($produto); ?>
    </tbody> 
</table>

  • You have already tried to change or add the parameter in the Toolbar links?

  • Scan the document http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#Htmlhelper::link

  • Yes Marcos, had given a read on the HTML helper only that I could not think of a solution rsrs but now I am studying heavy the documentation. And Jefferson yes, I even tried using a Jquery version, but my difficulty is capturing the parameter to put in the link. But vlw help guys, José Marcos there gave me a good idea, using Hidden, I will try. Thank you!

1 answer

0


Try to place the Id’s of your table inside the Hidden and then pass the values via post with the name of the field.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.