0

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:

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

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?

1 Answer 1

0

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->title ($node->nid)";

    }

Might not be the best way, but it works.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.