Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-marketplace-mod

    Add custom html content with dynamic rows in magento2

    Today, we will learn how to add new fields or custom html content with dynamic rows. When we add dynamic rows in ui component form by default, magento provides certain actions like delete to delete the added row. To know more on dynamic rows component within Magento2 you can follow the mentioned link

    Here I will show how we can add a new action like “View” or a custom button within dynamic rows. To create a form using ui component you can follow this link

    Below is the code of how to add dynamic rows in ui component form. Add the following code in your custom form.

    The dynamic row section will appear like this.

    Now let us add an action button just before the delete action button, we can do this by simply adding below code in our ui component form. You need to add this code right after <field> tag gets closed. Add the block path that you want to get initialised in this section and create a phtml file to render the output .

    Now create a block file within directory path Webkul\Test\Block\Adminhtml\CustomButton\Edit\Form as ViewCustom.php

    Next we need to create a phtml file where we will add our custom button like this.

    Now flush the cache and reload the form, it will appear like this. As we can see the html content will appear in position as per defined within your xml form. We can also include icons, fields in our phtml too.

    Similarly you can also create various custom actions like View and edit by including this in your form. To add other actions on button click we can also initialize js in the phtml and can customise the content according to our requirements.

    Hope this helps! If you have any queries please comment below.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close