0

My custom module uses an Admin Grid to display my model. I have added a link to my edit method with a button as follows:

$this->addColumn('action',
    array(
        'header' => 'Action',
        'width' => '50px',
        'type' => 'action',
        'getter' => 'getId',
        'actions' => array(
            array(
                'caption' => 'Edit',
                'url' => array(
                'base'=>'*/*/edit'
            ),
            'field' => 'store_id'
        )
    ),
    'filter' => false,
    'sortable' => false,
)
); 

Nine times out of 10 this works correctly and loads my Edit form with pre-filled data. However one on 10 clicks will load an empty form. This is because the link on the edit button is using id instead of store_id.

I’ve tried playing around with the ID’s on the addColumn() method about but it seems futile this the error is erratic. Even when a link is incorrectly constructed for a row, the other rows will be correct. Further it’s not the same row(s) that experience this behavior.

Really not sure hat else to try.

Bob.

1 Answer 1

0

I found the cause of this issue, hopefully the solution may help others who might experience this.

My getRowUrl method was the cause of the issue, I was using the incorrect paramater 'id' instead of 'store_id':

public function getRowUrl($row) {
         return $this->getUrl('*/*/edit', array('store_id' => $row->getId()));
}

Obvious in hindsight but easy to over-look.

Your Answer

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

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