I can't seem to detect a button press in cakephp4. In cake3 it was easy.
In Form I have:
echo $this->Form->button('View Data', [
'name' => 'viewdata',
'type' => 'submit',
'class' => 'btn btn-primary'
]);
In Controller I have:
if ($this->request->is('post') ) {
....
debug($this->request->getDdata());
if (!empty($this->request->getData('viewdata'))) {
I click the button and I see 'viewdata'=''
so it detects the button has been clicked but its made the value = null
? and I can't invoke the button press function of viewdata
.
https://book.cakephp.org/4/en/views/helpers/form.html#creating-buttons-and-submit-elements
question from:https://stackoverflow.com/questions/65920155/how-to-detect-which-button-was-used-to-submit-the-form