Problem with postlink in cakephp

0

I'm a novice with cakephp and I'm creating a form to add, edit and delete records. The problem is that I try to make the delete link look like a button, I have achieved it with css, creating a button class to which I gave a style. The issue is that I do not understand 2 things:

1) What is the difference between link and postlink? 2) If I apply the class button to postlink ignores it, how can I apply the style of the button class?

I copy the code:

<h1>Listado de Usuarios</h1>
<p><?php echo $this->Html->link("Agrega Nuevo", array('action' => 'add')); ?></p>
<table>
    <tr>
        <th>Id</th>
        <th>Nombres</th>
        <th>Apellidos</th>
        <th>Sector</th>
        <th>Teléfonos</th>
        <th>@mail</th>
        <th>Acciones</th>
    </tr>
    <?php foreach ($registros as $registros):?>
        <tr>
            <td><?php echo $registros ['Maestro']['id'];?></td>
            <td><?php echo $registros ['Maestro']['nombre'];?></td>
            <td><?php echo $registros ['Maestro']['apellido'];?></td>
            <td><?php echo $registros ['Maestro']['sector'];?></td>
            <td><?php echo $registros ['Maestro']['tele'];?></td>
            <td><?php echo $registros ['Maestro']['email'];?></td>
            <td>
                <?php echo $this->Html->link("Editar", array('controller' => 'maestros', 'action'=>'editar', $registros['Maestro']['id']), array('class' => 'button')); ?>
                <?php echo $this->Form->postlink('Eliminar', array('action' => 'eliminar', $registros['Maestro']['id']), array('confirm'=>'Eliminar a ' . $registros['Maestro']['id']), array('class' => 'button')); ?>
            </td>				
        </tr>
    <?php endforeach;?>
</table>

As I said, in the echo that leads to 'edit', it takes the 'button' style perfectly, in which it leads to 'Delete', ignores it ... I will appreciate any help!

    
asked by look68 29.12.2016 в 22:02
source

2 answers

1

These are the parameters that the helper expects to receive

FormHelper::postLink(string $title, mixed $url = null, array $options = array ())

So the class you have to put it within options remaining like this:

<?php echo $this->Form->postlink('Eliminar', array('action' => 'eliminar', $registros['Maestro']['id']), array('confirm'=>'Eliminar a ' . $registros['Maestro']['id'], 'class' => 'button')); ?>

Here you have more info: link

    
answered by 30.12.2016 / 13:29
source
1

In the case of link it is simply a link to an external url, as a <a href="url"></a> , when it takes http it takes it as external and when it does not search within the domain.

In the case of postlink a form is created with GET or POST depending on the configuration that you give it.

    
answered by 29.12.2016 в 22:54