How to call an ACTION from a specific CONTROLLER via a Button?

Asked

Viewed 407 times

0

Using the following code:

    $this->Html->link(
          'Meus Dados', array(
                   'controller' => 'Groups', 
                   'action' => 'index'
           )
     );

The HTML link is created normally, but if I want to put a BUTTON in place of the LINK, to make it redirected to a specific CONTROLLER ACTION when clicking on it, it does not work.

I’m doing like this:

    echo $this->Form->button(
        'Meus Dados', array(
             'label' => '', 
             'style' => 'width: 100%, color: lightslategray', 
             'class' => 'topnav input-append fa fa-twitter fa-fw', 
             'url' => array(
                      'controller' => 'Groups', 
                      'action' => 'index')
         )
    );

But nothing happens when I click the button, what I’m doing wrong?

1 answer

1


The page URL has to be on FORM and not in the BUTTON

echo $this->Form->create($row, [
    'url' => [
        'controller' => 'Groups',
        'action' => 'index'
        ]
    ]);


    echo this->Form->button('Enviar');

echo $this->Form->end();
  • Perfect, that’s exactly what I wanted @Jeferson-Asis !!

Browser other questions tagged

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