Many times we face the issue of having a listing of customers or products inside a form for mass selection. Magento UIComponent has provided a very useful feature which we can use to solve such issues. InsertListing UI Component is basically a component which allows us to insert the listing with all its features such as pagination, mass-actions, sorting, inside other UI Components.
Today, we are going to insert a product listing inside our form. Our purpose is to mass select the product and save it in the database. I will show you two different ways you can add the listing :-
1-Directly in the form
This will insert the product listing in your form.
2-Using a modal
This will display a link for product selection
Now add the code for modal which will have our insertListing component
Now our modal with listing is ready.
Saving
On our save controller, we can get our selected rows of listing by using below code.
$this->getRequest()->getParam(‘namespace-of-your-listing’);
In our case the namespace was ‘product_listing’, so the code will be :-
$this->getRequest()->getParam(‘product_listing’);
The post Use of UiComponent InsertListing – How to insert a listing inside a Form Element appeared first on CedCommerce Blog.