0

I have something like in my custom module:

$fieldset->addField('orderinfo', 'link', array(
      'label'     => Mage::helper('web')->__('Order Info'),
      'style'   => "",
      'href' => Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array('order_id' => $order_id)),
      'value'  => 'Magento Blog',
      'after_element_html' => '',
    ));

And as you can see from the code, I am trying to link that field to the Order Tab in the back-end. I'm having trouble getting the ID though. I'm planning to just save the Order ID in the database and then using the addField I could have the correct URL.

But how can I save an addField value to a variable? I want to store the value in "$order_id". Is it possible?

1

I am not sure in which context you are using this fieldset but if it is used for example for creating or editing object you can try something like that:

In controller:

public function editAction()
{
    $id = $this->getRequest()->getParam('id');
    $model  = Mage::getModel('module/model')->load($id);
    Mage::register('model_name', $model);
}

and then in the block:

protected function _prepareForm()
{
    $model = Mage::registry('model_name');

    // add fieldset to form

    $fieldset->addField('orderinfo', 'link', array(
      'label'     => Mage::helper('web')->__('Order Info'),
      'style'   => "",
      'href' => Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array('order_id' => $model->getOrderId())),
      'value'  => 'Magento Blog',
      'after_element_html' => '',
    ));

    //rest of the elements
}
  • nice.. thank you empisoft.. this is exactly what I needed.. :) – severinolorillajr Feb 12 '13 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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