DrupalDrupal 6: Passing Arguments to a Form

Drupal 6: Passing Arguments to a Form

This is the form to which we are passing arguments to.
Remember that the first parameter that is received in the form is the $form_state

/*
 * My Form function
 * First parameter is &$form_state
 */
function my_form(&$form_state, $param1,$param2) {

    $form['heading'] = array (
        '#type' => 'markup',
        '#value' => $param1,
    );
   $form['submit'] = array (
        '#type' => 'submit',
        '#title' => $param2,
    );

    return $form;
}

This is the way to call the form – Use the drupal_get_form(form_name,arg1, arg2, …. )

$output = drupal_get_form('my_form',$arg1,$arg2);

Categories: Drupal

Comments

  1. Emko

    January 26, 2012 8:52 pm

    Yes, I've been looking for this answer all day. Thanks
  2. January 17, 2011 1:01 pm

    Thanks for the tricks.... It was very helpful for me.

Post a comment

Your email address will not be published. Required fields are marked *