I have an XML form on the backend. It has the save button the code for which is this -
class SaveButton implements \Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface {
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Framework\UrlInterface $urlInterface,
\Magento\Framework\App\RequestInterface $request
) {
$this->urlBuilder = $context->getUrlBuilder();
$this->urlInterface = $urlInterface;
$this->request = $request;
}
public function getButtonData()
{
$productId = $this->request->getParam('id');
return [
'label' => __('Save'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => ['button' => ['event' => 'save']],
'form-role' => 'save',
],
'onclick' => $this->urlBuilder->getUrl( '{moduleName}/{controllerName}/save','product_id' => $productId ] ),
'sort_order' => 90,
];
}
When I click on save, it just reloads the page and doesn't take the control to the save controller.
Thanks!