How to Call Adminhtml Controller on Form Action in Magento 2

custommagento2

I have created a custom module.
Which adds a custom tab on product_edit page.
Custom tab have multiple images and text boxes.
this all include in 1 custom form like this…

<form action="<?php echo $baseurl.'admin/AdminSample/sampleOne';?>" method="post" enctype="multipart/form-data">

and i want on Save button click the form should call controller in which i can handle all posted data.

I have tried call controller using basepath, but it always redirect me to admin dashboard.

Best Answer

Calling of admin url of echo $baseurl.'admin/AdminSample/sampleOne'; is not wrong idea.

If you want call admin url then you should try

$this->getUrl('AdminSample/sampleOne')

at block class.

Related Topic