I have a controller with custom function getPost(). I want to call this function from my phtml
My phtml code:
<form id="my-form" method="POST" action="<?php echo $block->getUrl('nzrw/vendor/vendorsettingpost/getpost'); ?>">
<input name="costperitem" class="input-text" type="text" style="width: 100px" /><br />
<input type="submit" value="Save">
</form>
My Controller Code:
<?php
namespace Netzz\ShippingRework\Controller\Vendor;
use Magento\Framework\Controller\ResultFactory;
class Vendorsettingpost extends \Magento\Framework\App\Action\Action {
public function execute() {
$post = (array) $this->getRequest()->getPost();
public function getpost() {
$post = (array) $this->getRequest()->getPost();
if (!empty($post)) {
$costperitem = $post['costperitem'];
echo $costperitem;
die();
}
}
}
If I call the execute function, it's working fine, but when I call the getpost function from action, it's not working.