How to create a form using UI component in Magento 2
Hi Everybody, I am Cuong, Welcome to my Magento 2 Tutorial video series.
In the previous lessons, I showed everyone:
1. How to create a new module in Magento 2, at the video link
2. How to add new tables for a custom module in Magento 2, at the video link
3. How to create an adminhtml grid using UI component in Magento 2, at the video link
To continue the previous lessons, today, I am going to show everyone, How to create a form using UI component in Magento 2.
To complete this exercise you need to complete the following high-level steps:
1. Create the new action
– Create the new file named Edit.php in the path appcodePHPCuongBannerSliderControllerAdminhtmlBanner
– Create the new file named NewAction.php in the path appcodePHPCuongBannerSliderControllerAdminhtmlBanner
2. Create the new layout
– Create the new layout named phpcuong_banners_slider_banner_new.xml in the path appcodePHPCuongBannerSliderviewadminhtmllayout
– Create the new layout named phpcuong_banners_slider_banner_edit.xml in the path appcodePHPCuongBannerSliderviewadminhtmllayout
– The structure of a layout will be routeName_controllerName_actionName.xml
3. Create the new ui_component
– Create the new ui component named phpcuong_banners_slider_banner_form.xml in the path appcodePHPCuongBannerSliderviewadminhtmlui_component
4. Create the new buttons
– Create the buttons named Back, Delete, Reset, Save And Continute, Save
5. Create the DataProvider
– Create the file named DataProvider.php in the path appcodePHPCuongBannerSliderModelBanner
6. Flush the caches and See the results.
– php bin/magento cache:flush
I will resolve this problem in the next video. In this video, I only show everyone how to use the ui form in Magento 2.
Thank you for your watching. If you have any questions about this exercise please feel free to leave a comment below.
Don’t forget to like, comment, share and subscribe to my channel for getting the latest videos.
Please do not hesitate to contact me if you need me to join your Magento project. My rate is $25/hour in Magento 1 and $30/hour in Magento 2.
Get the source codes of this tutorial on the github