Note that there are some explanatory texts on larger screens.

plurals
  1. POcakephp call action through button
    text
    copied!<p>i wish to call a controller's action through form->button. I have following things in the web page:</p> <ul> <li>a search form</li> <li>a table with delte option as postLink</li> <li><p>2 buttons that should call the same action onclick. My problem is that when i click on any of the buttons, the post request isn't fired. Below is my code: view.ctp</p> <p>echo $this->Form->create('Search', array( 'type' => 'file', 'url' => array( 'controller' => 'artists', 'action' => 'index', ), )); echo $this->Form->input('name'); echo $this->Form->end(array( 'label' => 'Search Artist', 'class' => 'btn btn-info controls' ));</p> echo $this->For.... <pre><code>echo '' . $this-&gt;Form-&gt;postlink('', array('action' =&gt; 'delete', $row['Artist']['id']), array('confirm' =&gt; 'Are you sure?') ); </code></pre> <p>echo $this->Form->button('Featured', array( 'name' => 'submit', 'value' => 'Featured', 'type' => 'submit', 'url' => array( 'controller' => 'artists', 'action' => 'index', ), ));</p> <p>echo $this->Form->button('Unfeatured', array( 'name' => 'submit', 'value' => 'Unfeatured', 'type' => 'submit', 'url' => array( 'controller' => 'artists', 'action' => 'index', ), ));</p></li> </ul> <p>controller:</p> <pre><code>public function isFeatured() { if ($this-&gt;params-&gt;data['submit'] == 'Featured') { //code } else if($this-&gt;params-&gt;data['submit'] == 'Unfeatured') { //code } $this-&gt;redirect(array('action' =&gt; 'index')); } </code></pre> <p>where am i getting wrong? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload