Using admin forms I would like to add a facility which will allow a user to upload an image and link it to some data held within other tables. My database is set up and my form is set up as required, unfortunately I have been unsuccessful in working out how to pass the id value from the url to the field on my form

How do I pass the id value from the url to the field on my form?

I have this

protected function _prepareForm()
    ....Other code here....

    $fieldset->addField('shop_id', 'hidden', array(
        'value'     => //unable to work out what command needs to be added,
        'name'      => 'shop_id',

1 Answer 1


Add this at the end of the form configuration


Or you can make the form submit to an url that has a get parameter named shop_id with the value of the shop id you need (I mean pass the get param shop_id to the page that handles the save action).

  • I have been getting confused how pages pass data and as a result was calling the wrong registry (one of many issues I was facing). I have taken the second option you mentioned. My next task is to get a more complete understanding of admin forms.
    – tony09uk
    May 27, 2014 at 13:36

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.