Entity form in ctools modal popup, whilst passing in values from current node I need to open an entityform in a modal popup. I have got this working using 'Modal operations'‎ and 'Modal forms' modules following this guide: http://julian.pustkuchen.com/en/comment/reply/599. My link looks like the following:

&lt;a href="modal/entityform/job_application/nojs/0" class="ctools-use-modal ctools-modal-modal-popup-large btn"&gt;&lt;?php print t('Apply') ?&gt;&lt;/a&gt;


The problem now is that I need to pass certain data (e.g. the nid) of the currently viewed node into the entityform.

I am happy to use hook_form_alter or similar, but obviously hooking the entityform has no knowledge of the currently viewed node. My other, pretty hacky, idea was to grab data with javascript and put it in that way, but I need some sort of popup event to work from, which I don't think exists.

Is there another approach to this I could be using, or am I going down the right track?
If anyone's interested in the answer, I just appended ?nid=5 to the end of the link url. Then I could just hook_form_alter to get the nid:

if($form['#id'] == 'whatever-entityform-edit-form'){

        $nid = $_GET['nid'];
        $node = node_load($nid);

        $form['field_whatever'][LANGUAGE_NONE][0]['target_id']['#default_value'] = "$node-&gt;title ($node-&gt;nid)";

    }


Might not be the best way, but it works.