3

I have two login boxes on the same page and, I would like to integrate different behaviors to those based on some arguments.

I'm calling myself the forms with drupal_get_form('user_login');. I would like to pass a variable to the form:

drupal_get_form('user_login', $myvar);

And then be able to get it from a hook_form_alter():

function mymodule_form_alter($form, $form_state, $form_id, $myvar) {
  // some code here
}

But i can't find a way to do this.

1
  • hook_form() is something completely else, I assume you mean hook_form_alter().
    – Berdir
    Oct 26, 2011 at 5:58

1 Answer 1

9

The passed arguments are kept in $form_state['build_info']['args']. You can find a documentation of the $form_state structure here: drupal_build_form().

2
  • My question was for D6, anyway thanks a lot, the answer you gave helped me finding the right solution for D6: The arguments are in $form['#parameters'][argument]; Oct 26, 2011 at 14:49
  • Search about one day to find this one here. Works great. Just giving the register form a string and reading it out via the build_info. Cool.
    – kwoxer
    Jul 12, 2016 at 9:34

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.