I need to insert a grid inside the admin form having two columns and each row should be having a delete button. Is there a way to achieve this
Admin Form Grid – How to Insert a Grid with Columns Inside an Admin Form
adminformadminhtmlformsgrid
adminformadminhtmlformsgrid
I need to insert a grid inside the admin form having two columns and each row should be having a delete button. Is there a way to achieve this
Best Answer
You need a couple of things. First of all next to the normal
table
you'll have created for your module that stores the data of theadminhtml
form you need a secondtable
that stores the URLs data with the fieldsCreate the resource models accordingly.
Rendering in the Adminhtml
Adding a new renderer to the form generator. I've just added the field that will have the renderer
app/code/[codepool]/Namespace/Module/BLock/Adminhtml/[Module]/Edit/Tab/General.php
The renderer class that adds the phtml template
app/code/[codepool]/Namespace/Module/BLock/Adminhtml/[Module]/Edit/Renderer/Urls.php
And the template that renders the filled in options and adds a javascript template for the other rows.
app/design/adminhtml/default/default/template/[namespace]_[module]/urls.phtml
Storing the data on save
app/code/[codepool]/[Namespace]/[Module]/controllers/Adminhtml/[Module]Controller.php
Now earlier I've referenced to the method
getUrls
in the objects model. It would look something like this.app/code/[codepool]/[Namespace]/[Module]/Model/[Object].php
And that's it!