Magento Button Style – How to Get Button Style in Magento 1.7 and 1.8

magento-1.7magento-1.8template

I have created some form that opens in new popup window. And there i have some text, combo box and buttons and i would like to add to these buttons magento button style, but how can get this style?

My created form lays in there: app/design/adminhtml/default/default/template/mycompany/label.phtml

<html>
                   <h2>Select label size:</h2>        
                    <form action="LebelController.php" method="POST"><div>
                        <select name="SIZE">
                                 <option value="1x5">1x5</option>
                                  <option value="15x10">15x10</option>
                                  <option value="15x37">15x37</option>
                                  <option value="70x42">70x42</option>

                                </select>
                                <input type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey()?>" name="form_key">
                                <input type="submit" name="submit" value="Go" style="width: 100px; height:40px; font-size: 130%;"></p>
                        </form>
                   </html>

And this is my app/design/adminhtml/default/default/layout/mymodule.xml file

<mymodule_label_setlabel translate=”label”>
        <label>Label</label>
        <reference name=”root”></reference>
        <reference name=”content”>
            <block type=”mymodule/block_labelblock” name=”mymodule.labelblock” template=”mymodule/label.phtml”/>
        </reference>
 </mymodule_label_setlabel>

and finally this is my controller that opens in new window and shows my form:
app/code/local/MyCompany/MyModule/controllers/Adminhtml/LabelController.php

class MyCompany_MyModule_Adminhtml_LabelController
extends Mage_Adminhtml_Controller_Action
{
    public function setlabelAction()
        {
$output = $this->getLayout()->createBlock('core/template')->setTemplate('mycomapny/label.phtml')->toHtml();
                $this->getResponse()->appendBody($output);
}

i am wondering how can i add magento style to this button, if i could add also combo box magento style that would be also great. So how can i get this magento style for buttons?
p.s. this all happens in backend

Best Answer

You can do it like this:

$button = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
$button->setData(array(
    'label' => $this->__('Some label'),
    'type' => 'submit',
    'class' => 'button'
));

echo $button->toHtml();
Related Topic