- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2021
03:32 AM
07-05-2021
03:32 AM
How to handle a magento form request?
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?
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2021
03:35 AM
07-06-2021
03:35 AM
Re: How to handle a magento form request?
It'll be easy if you call Ajax on the click event of the button
Reference block for such :
Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.
200+ Magento 2 Extensions for Enhanced Shopping Experience.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2021
02:51 AM
07-24-2021
02:51 AM
Re: How to handle a magento form request?
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.