我正嘗試在Magento 2中創建一個自定義窗體,並且無法將窗體的動作發送給正確的文件。Magento 2中的自定義窗體
到目前爲止,我有以下的模塊結構(我省略了一些文件模型和CRUD這可能沒有必要在這裏,如果需要的話,我會在結構上添加它們):
- Block - Adminhtml * Main.php - Controller - Adminhtml - MySection * Settings.php * Save.php - etc - adminhtml * menu.xml * routes.xml * acl.xml * module.xml - Setup * InstallSchema.php - view - adminhtml - layout * modulename_mysection_settings.xml * modulename_mysection_save.xml - templates * mysectionContent.phtml * content.phtml * registration
等\ adminhtml \ routes.xml內容:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="modulename" frontName="modulename">
<module name="modulename"/>
</route>
</router>
</config>
視圖\ adminhtml \佈局\ modulename_mysection_settings.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">
<head>
<title>My Title</title>
</head>
<body>
<referenceBlock name="content">
<block template="mysectionContent.phtml"
class="Modulename\Block\Adminhtml\Main"
name="modulenameadminbackend_block_main"/>
</referenceBlock>
</body>
</page>
視圖\ adminhtml \模板\ mysectionContent.phtml
<h1>My H1 Title</h1>
<form class="form" action="save" method="post">
<fieldset class="fieldset">
<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Test Form') ?></span></legend><br>
<div class="field required">
<label for="number" class="label">
<span><?php /* @escapeNotVerified */ echo __('Input') ?></span>
</label>
<div class="control">
<input type="text" id="number" name="number" class="input-text">
<input name="form_key" type="hidden" value="<?php /* @escapeNotVerified */ echo $block->getFormKey() ?>" />
</div>
</div>
</fieldset>
<div class="actions-toolbar">
<div class="primary">
<button type="submit" class="action submit primary" title="<?php /* @escapeNotVerified */ echo __('Submit') ?>">
<span><?php /* @escapeNotVerified */ echo __('Submit') ?></span>
</button>
</div>
</div>
</form>
有,我可以指導的形式,它的行動將是文件控制器/ Adminhtml/MySection/Save.php的方法嗎?如果控制器文件不是要提交表單的正確位置,請告訴我應該在哪裏以及如何執行此操作。之後,我需要從該文件中檢索提交的變量變量。 我在Magento的新的和我似乎無法能夠找到關於提交表單
我應該將此問題移至[Magento Stack Exchange](https://magento.stackexchange.com)嗎? –