2

Is it possible in magento to send parameter to controller form?

    $x=987654;
    $url=Mage::helper("adminhtml")->getUrl("/label/setlabel");
    $block->addButton('label', array(
                     "label" => "Get Label",
                     "onclick" =>"popWin('$url', 'windowname', 'width=400,height=300,scrollbars=yes')
                                    )
    );"

controller file:

class MyCompany_MyModule_Adminhtml_LabelController
extends Mage_Adminhtml_Controller_Action
{
    public function setlabelAction()
        {
           echo $x;//is this possible?
        }
}

I have this $x parmeter, is it possible somehow to send it to controller and echo it there?

Julien Lachal
  • 1,583
  • 16
  • 33
user6398
  • 145
  • 3
  • 13

1 Answers1

7

You can send that parameter through GET by making the url look like this:

$url=Mage::helper("adminhtml")->getUrl("/label/setlabel", array('param_name'=>$paramValue));

So in your case it can be

 $url=Mage::helper("adminhtml")->getUrl("/label/setlabel", array('x'=>$x));

Then you can read it in the controller like this:

$x = $this->getRequest()->getParam('x');
Marius
  • 197,939
  • 53
  • 422
  • 830