2

I have UI admin form xml file.

I've got SaveButton.php block file, but I need to save form in db. As far as I know I need controller.

How this controller would look like and in which directory it should be stored?

2

1 Answer 1

2

The location of the Save Controller class largely depends on UI Component configuration.

For example, the dataSource settings for the Customer UI form looks like this:

<dataSource name="...">
    <settings>
        ...
        <submitUrl path="customer/index/save"/>
    </settings>

This path leads us to a Controller file here:

vendor/magento/module-customer/Controller/Adminhtml/Index/Save.php

Following a similar pattern makes sense.

I suggest creating a data object from a data factory and then saving the object via it's repository.

https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-form.html https://devdocs.magento.com/guides/v2.3/extension-dev-guide/service-contracts/design-patterns.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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