Magento2 Magento 2管理表单显示空白页
我正在构建一个后端页面来在数据库中创建项目。 “我的管理员表单”页面将显示,但仅显示以下标题。没有表单元素,以下是代码: 下面是代码Vendor\Events\Controller\Adminhtml\Post\Addevent } View/Adminhtml/layout/vendor\u events\u addevent.xmlMagento2 Magento 2管理表单显示空白页,magento2,Magento2,我正在构建一个后端页面来在数据库中创建项目。 “我的管理员表单”页面将显示,但仅显示以下标题。没有表单元素,以下是代码: 下面是代码Vendor\Events\Controller\Adminhtml\Post\Addevent } View/Adminhtml/layout/vendor\u events\u addevent.xml View/Adminhtml/ui\u component/vendor\u events\u addevent\u listing.xml 供应商事件
View/Adminhtml/ui\u component/vendor\u events\u addevent\u listing.xml
供应商事件。供应商事件列表数据源
供应商事件。供应商事件列表数据源
员工信息
数据
雇员登记表
模板/表单/可折叠
Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider
woodmizer\u事件\u列表\u数据\u源
pri_id
pri_id
Magento_Ui/js/form/provider
真的
员工详细信息
20
文本
员工Id
输入
雇员
雇员身份证
您的文件名错误。您的控制器是
Vendor\Events\controller\Adminhtml\Post\Addevent
,在etc/Adminhtml
文件夹中,您应该有一个routes.xml
,它告诉Magento模块资源的位置
当Magento为这些页面创建URL时,它会查找/
,在您的例子中,它是/post/addevent
。您的布局需要命名为\u post\u addevent.xml
和UI组件\u addevent\u listing.xml
。您需要相应地更换
。然后,只要您的模型和di.xml是它们应该的样子,(我假设它们是)。然后,您可以重新运行主Magento命令,并且您应该有一个可以在管理员界面中查看的页面
Magento命令方面,为了安全起见,我通常会使用
setup:upgrade
和setup:di:compile
。确保更新布局文件中的路径,使之与用于UI组件的路径相匹配。文件名错误。您的控制器是Vendor\Events\controller\Adminhtml\Post\Addevent
,在etc/Adminhtml
文件夹中,您应该有一个routes.xml
,它告诉Magento模块资源的位置
当Magento为这些页面创建URL时,它会查找/
,在您的例子中,它是/post/addevent
。您的布局需要命名为\u post\u addevent.xml
和UI组件\u addevent\u listing.xml
。您需要相应地更换
。然后,只要您的模型和di.xml是它们应该的样子,(我假设它们是)。然后,您可以重新运行主Magento命令,并且您应该有一个可以在管理员界面中查看的页面
Magento命令方面,为了安全起见,我通常会使用setup:upgrade
和setup:di:compile
。请确保更新布局文件中的路径,使其与用于UI组件的路径相匹配
namespace Vendor\Events\Controller\Adminhtml\Post;
class Addevent extends \Magento\Backend\App\Action
{
protected $resultPageFactory = false;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
)
{
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend((__('Vendor Create an Event')));
return $resultPage;
}
<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">
<uiComponent name="vendor_events_addevent_listing"/>
</referenceContainer>
</body>
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">vendor_events.vendor_events_listing_data_source</item>
<item name="deps" xsi:type="string">vendor_events.vendor_events_listing_data_source</item>
</item>
<item name="label" xsi:type="string" translate="true">Employee Information</item>
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data</item>
<item name="namespace" xsi:type="string">employee_form</item>
</item>
<item name="template" xsi:type="string">templates/form/collapsible</item>
</argument>
<dataSource name="employee_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">woodmizer_events_listing_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">pri_id</argument>
<argument name="requestFieldName" xsi:type="string">pri_id</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
<fieldset name="employee_details">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="collapsible" xsi:type="boolean">true</item>
<item name="label" xsi:type="string" translate="true">Employee Details</item>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
<field name="employee_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Employee Id</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">employee</item>
<item name="dataScope" xsi:type="string">employee_id</item>
</item>
</argument>
</field>
</fieldset>