0
votes

Is it possible to create a submit 'link' with CakePHP 2.4's FormHelper? I'm trying to put some less-used submit buttons from my POST form into a Bootstrap dropdown and am running into trouble since they only seem to be able to create a button, which won't work in a dropdown.

Since this is inside a form already, clearly this isn't what I want a postLink for- but is there any good Cake way around this? postLink just makes a plain link, but it won't play well inside another form.

echo $this->Form->button('Download Excel CSV', array(
                    'type' => 'submit',
                    'class' => '',
                    'formaction' => '/posts/csv',
                ));
1

1 Answers

0
votes

Just use the HtmlHelper's url() method:

<button type="button" formaction="<?php echo $this->Html->url('/posts/csv'); ?>">
    Click Here
</button>

(I realize you don't want it in a button element, but - showing the concept).


Side note: you should really be using an array instead of a hard-coded formaction:

$this->Html->url(array('controller'=>'posts', 'action'=>'csv'));