1

I want to add a new section in product edit form with form element(file uploader) for that I created the product_form.xml and added the required fields.to get the input data, I use a catalog_product_save_after observer.issue is data that is input to the form field is not coming in the request.

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="attachment_products" sortOrder="30">
    <settings>
        <collapsible>true</collapsible>
        <label translate="true">Document Attachments</label>
    </settings>

    <field name="attachment_product" sortOrder="110" formElement="fileUploader">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="source" xsi:type="string">product</item>
            </item>
        </argument>
        <settings>
            <elementTmpl>ui/form/element/uploader/image</elementTmpl>
            <dataType>string</dataType>
            <label translate="true">file Image</label>
            <visible>true</visible>
            <notice translate="true">Maximum file size: 2 MB.  Allowed file types: JPEG, GIF, PNG, JPG, PDF</notice>
        </settings>
        <formElements>
            <fileUploader>
                <settings>
                    <uploaderConfig>
                        <param xsi:type="url" name="url" path="achmentsadmin/files/upload"/>
                    </uploaderConfig>
                    <allowedExtensions>jpg jpeg gif png pdf</allowedExtensions>
                    <maxFileSize>4194304</maxFileSize>
                </settings>
            </fileUploader>
        </formElements>
    </field></fieldset>
</modal>

but when I add the following code after the form tag and wraps the whole fieldset tag, I can get the data from the post request.

<modal name="advanced_inventory_modal"></modal>

but it adds inside the advance inventory section. I want to add as a separate tab.can you please let me know the issue here Thanks

  • thanks for the answer. but I prefer doing it using the UI component. any idea why it works in a different way as I explained in the above question? – Kevin Feb 20 at 13:07
0

I think the best solution to add a new section in the product edit section is either using setup script and adding required attributes or using modifiers.I followed this tutorial and found the answer

https://www.mageworx.com/blog/2016/08/an-easy-way-to-add-a-fieldset-with-fields-to-the-ui-form/

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.