I created a new menu item, lets call it “My menu item”. Its shown in the admin area of Magento.If the new item is clicked, I Dont want to show a grid, but a simple form with some text fields and a button the should trigger an action. How would I do that? All examples I found created a grid to display data, thats not what I want. I just want a form right “behind” my menu item
Is that possible?
Thanks!
Yes its completely possible as the framework is extensible in nature. Why dont you do the following.
1.) Make sure your adminhtml controller is working.
2.) create the action you have specified in the action tag in your menu item.
3.) in said action simply :
thats all need for the controller. At this point you should be loading the standard magento admin layout. So you want to add a form to the page? Ok, easy.
4.) Declare a layout xml file for your module. i.e. in your etc/config.xml i.e.
place this outside of the global node.
so where would you place this file?
well thats up to you, but I would suggest putting it in app/design/adminhtml/default/default/layout
what is this file for? well we can register a block and set a template file to it.
the file could look something like
so the next steps would be
5.) declare a new block following how you are referencing it in your layout xml file
EDIT : To clarify on the block file, continuing with the example, create a file in you module directory, under Block/Adminhtml and name it “Yourblock.php” or whatever you would like to, making sure it corresponds to your block declaration :
Here is an example of what the Block Class could look like :
6.) Create a template file and place it correclty, in my example place it in
app/design/adminhtml/default/default/template
add your php form to it (or some standard html to check its working properly)
thats it (in terms of displaying a form – of course you now need to create actions to accept your form POST and all the rest of it).
To recap.