2

I have created a UI form in admin but I am not able to receive form data in save controller. Following is my code in ui_component

<?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">my_edit_form.edit_form_data_source</item>
        </item>
        <item name="label" xsi:type="string" translate="true">My Information</item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <settings>
        <buttons>
            <button name="save" class="Anshu\MyManagement\Block\Adminhtml\My\Edit\SaveButton"/>
            <button name="back" class="Anshu\MyManagement\Block\Adminhtml\My\Edit\BackButton"/>
        </buttons>
        <namespace>my_edit_form</namespace>
        <dataScope>myManagement</dataScope>
        <deps>
            <dep>my_edit_form.edit_form_data_source</dep>
        </deps>
    </settings>
    <dataSource name="edit_form_data_source">
        <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>
        <settings>
            <submitUrl path="my/my/save"/>
        </settings>
        <dataProvider class="Anshu\MyManagement\Model\DataProvider" name="edit_form_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <fieldset name="details">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="collapsible" xsi:type="boolean">false</item>
                <item name="label" xsi:type="string" translate="true">My Information</item>
                <item name="sortOrder" xsi:type="number">10</item>
            </item>
        </argument>
        <field name="name" formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">myManagement</item>
                </item>
            </argument>
            <settings>
                <dataType>text</dataType>
                <label translate="true">Name</label>
                <dataScope>name</dataScope>
            </settings>
        </field>
        <field name="description" formElement="textarea">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">myManagement</item>
                </item>
            </argument>
            <settings>
                <dataType>text</dataType>
                <label translate="true">Description</label>
                <dataScope>description</dataScope>
            </settings>
        </field>
    </fieldset>
</form>
  • Why are you using multiple field name="description"? – Mohit Kumar Arora Aug 30 '18 at 13:39
  • 2
    try changing <dataScope>myManagement</dataScope> to <dataScope>data</dataScope> – Marius Aug 30 '18 at 13:48
  • Can you please add your save controller code here? – Rutvee Sojitra Aug 30 '18 at 13:50
  • @MohitKumarArora I have added that by mistake, I have removed that now. – Anshu Mishra Aug 31 '18 at 4:22
  • 1
    I don't think I can explain it properly. All I know is that in the core forms this is the value used everywhere. – Marius Aug 31 '18 at 5:08
2

As per @Marius comments, I have changed <dataScope>myManagement</dataScope> to <dataScope>data</dataScope> and now form data is getting passed to save controller.

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.