2

form not showing when I click on the menu that I created custom module.

Here's my code:

/home1/dukaania/public_html/testing2/app/code/Test/Banners/etc/adminhtml/menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
    <add id="Test_Banners::first_level_demo"
         title="Shipping Vendor"
         module="Test_Banners"
         sortOrder="9999"
         resource="Magento_Backend::content" />



          <add id="Test_Banners::second_level_demo"
         title="Shipping Vendor Cost"
         module="Test_Banners"
         sortOrder="0"
         action="uiform/"
         parent="Test_Banners::first_level_demo"
         resource="Magento_Backend::content" />
</menu>

/home1/dukaania/public_html/testing2/app/code/Test/Banners/etc/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="uiform" frontName="uiform">
        <module name="Test_Banners"/>
    </route>
</router>

/home1/dukaania/public_html/testing2/app/code/Test/Banners/view/adminhtml/layout/ui_component/employee_form.xml

<?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">employee_form.employee_form_data_source</item>
        <item name="deps" xsi:type="string">employee_form.employee_form_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">Test\Banners\Model\DataProvider</argument>
        <argument name="name" xsi:type="string">employee_form_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">id</argument>
        <argument name="requestFieldName" xsi:type="string">id</argument>
    </argument>
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="component" xsi:type="string">Test/Banners/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>
    <field name="employee_name">
        <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 Name</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">employee</item>
                <item name="dataScope" xsi:type="string">employee_name</item>
            </item>
        </argument>
    </field>
    <field name="employee_salary">
        <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 Salary</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">employee</item>
                <item name="dataScope" xsi:type="string">employee_salary</item>
            </item>
        </argument>
    </field>
    <field name="employee_address">
        <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 Address</item>
                <item name="formElement" xsi:type="string">textarea</item>
                <item name="source" xsi:type="string">employee</item>
                <item name="dataScope" xsi:type="string">employee_address</item>
            </item>
        </argument>
    </field>
</fieldset>

/home1/dukaania/public_html/testing2/app/code/Test/Banners/Controller/Adminhtml/Employee/Index.php

<?php
namespace Test\Banners\Controller\Adminhtml\Employee;

use Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Backend\App\Action\Action
{
protected $_pageFactory;

/**
 * Index constructor.
 * @param \Magento\Framework\App\Action\Context $context
 * @param \Magento\Framework\View\Result\PageFactory $pageFactory
 */
public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $pageFactory)
{
    $this->_pageFactory = $pageFactory;
    return parent::__construct($context);
}


/**
 * @return \Magento\Framework\View\Result\Page
 */
public function execute()
{
    return $this->_pageFactory->create();
}
}
  • Please add your controller code in question – Rutvee Sojitra Sep 25 '18 at 5:08
  • added please review it – jhon jhon doe Sep 25 '18 at 5:40
0

In your menu.xml file you have given action "uiform" you have to give "*/employee/index"

   <add id="Test_Banners::second_level_demo"
     title="Shipping Vendor Cost"
     module="Test_Banners"
     sortOrder="0"
     action="*/employee/index"
     parent="Test_Banners::first_level_demo"
     resource="Magento_Backend::content" />
0

Add file uiform_index_index.xml in Vendor/Module/view/adminhtml/layout

<?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">
            <!-- here we call our ui component of grid-->
            <uiComponent name="employee_form"/>
        </referenceContainer>
    </body>
</page>
  • still my form not showing error 404 – jhon jhon doe Sep 25 '18 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.