I'm using CakePHP 3.4
I have a form with two submit buttons like
<?= $this->Form->create($post) ?>
<?= $this->Form->control('title') ?>
<button name="submit_type" value="draft" type="submit">Draft</button>
<button name="submit_type" value="publish" type="submit">Publish</button>
<?= $this->Form->end() ?>
According to w3schools button value is also sent to server.
But when I debug
debug($this->request->getData('submit_type'));
it gives NULL
. Also debugging getData()
, it gives only title
field.
How to get value of submit
button?
I had the same problem. Try to use "input type" instead of "button", like
Hope, this will help you. :)