I'm creating a custom form in Magento 2.3 admin.
Vendor/Module/view/adminhtml/layout/route_folder_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Vendor\Module\Block\Adminhtml\NewFunction\Edit" name="newfunction.form.container" template="newfunction.phtml"/>
</referenceContainer>
</body>
</page>
Vendor/Module/Block/Adminhtml/NewFunction/Edit.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Export edit block
*
* @author Magento Core Team <[email protected]>
*/
namespace Vendor\Module\Block\Adminhtml\NewFunction;
/**
* @api
* @since 100.0.2
*/
class Edit extends \Magento\Backend\Block\Template
{
public function getNewFunctionUrl()
{
return $this->getUrl('route/folder/newfunction');
}
}
Vendor/Module/view/adminhtml/templates/newfunction.phtml
<form action="<?php echo $block->getNewFunctionUrl()?>" method="post" enctype="multipart/form-data">
<input type="text" name="hello"/>
<input type="submit" value="Submit" />
</form>
Vendor/Module/Controller/Adminhtml/Folder/NewFunction.php
<?php
namespace Vendor\Module\Controller\Adminhtml\Folder;
class NewFunction extends \Magento\Framework\App\Action\Action
{
public function execute()
{
$params = $this->getRequest()->getParams();
}
}
The form submits perfectly but when I debug the $params variable it shows only two parameters
key
adminhtml
I was expecting the hello text as one of the parameter but didn't receive one on form submit.
Is there anything wrong with the process or code?