I created a button inside order view which is created in this way:
$onclick = "submitAndReloadArea($('order_sendsms').parentNode, '" . $this->getSubmitUrl() . "')"; $button = $this->getLayout()->createBlock( \Magento\Backend\Block\Widget\Button::class )->setData( ['label' => __('Send'), 'class' => 'action-save action-secondary', 'onclick' => $onclick] ); $this->setChild('submit_button', $button); return parent::_prepareLayout();
but I don't really know where I should submit the button to. I tried creating a controller but it did not receive the request. My goal is to have a button, execute something in PHP and show a success or fail message. How to achieve this?
It'll be easy if you call Ajax on the click event of the button
If you are in production mode and seeing this error (Invalid security or form key)
The run setup:upgrade and other respective commands. Then try click on the button.