Append table layout rows

Its there any others way able to append the table row in Yii2 instead of using JavaScript? What I gonna do is there will be a table form for my page and when click on add button, I want the table add new row for me. I am able to make it by using the JavaScript, but now I am looking for the other alternative way to do it. Thanks.

You can do two things to add rows dynamically (you need javascript either way):

  • Clientside cloning

  • Ajax-based cloning

Client cloning is done solely in javascript on the client side and is good for simple display - for example, where validation is not required and you don’t need the server to retrieve or process the output of what is being cloned.

If you need more complex workflow (look up something on the server to populate the response, need validation of what is entered prior to cloning, etc) you can use an ajax mechanism to submit data to the server and get the response back as JSON or HTML to append to the table.

Thank you for your advised.