I see that in the latest versions of Magento 2, the add/edit form for categories, blocks and pages are generated via a ui component form xml.
Here is the example for cms pages.
I want to use that for my own module like the big boys do.
I got most of the things figured out, but I wasn't able to add a fieldset that retrieves its contents via AJAX.
For example, I want to associate my custom entity "many to many" with the products, so I need a fieldset that contains nothing at first, but when is clicked it will retrieve the list of products via an ajax call.
I don't need the actual products grid code. All I need is a way to do an ajax call when clicking the fieldset header.


1 Answer 1


All I need is a way to do an ajax call when clicking the fieldset header.

Currently Fieldset Ui Component doesn't suport such ability: click on fieldset -> load content via AJAX .

1) You can implement it by yourself

Take a look on fieldset.js. It can be easily extended with custom behavior. In same maner as fieldset.js extends collapsible.js.

2) You can use InsertListing Ui Component

As was pointed above its js part is a insert-listing.js file.

Sample can be used like this:

<insertListing name="testListingInsert">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="autoRender" xsi:type="boolean">true</item>
            <item name="ns" xsi:type="string">cms_page_listing</item>

Where to put this?

In any Form Ui Component under <fieldset>'s or <container>'s.

What does component do?

It uses namespace ns as a locator for some Ui Component, loads it, and instantiate in place.

cms_page_listing is a name of configured Listing Ui Component.

  • Thanks. I will give it a try tomorrow and come back with the results.
    – Marius
    Feb 9, 2016 at 18:55
  • nice, i was nearly that far ;) But I'm using the 2.0.2 where the insertListing is not implemented yet. I tried to add it manually by adding the component js file and then update the configuration files, but I seem to miss sth. maybe I' try in develop later Feb 9, 2016 at 19:12
  • Yes, David, you are right: it miss something. There were changes in core js files to support such behavior :(
    – Anton Huz
    Feb 9, 2016 at 19:20
  • I wasn't able (yet) to achieve the desired behavior but this is just because of my capacity to understand what's going on in there. I will accept this answer as I did some tests as suggested and it and it looks like the way to go. I will accept the answer and post a full solution if/when I find one, but I really hope this will become a core feature soon.
    – Marius
    Feb 10, 2016 at 6:52

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.