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?

0

1 Answer 1

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');
1
  • damn Marius, you're too fast May 19, 2014 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.