Home > Drupal > Drupal 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);
Advertisements
Categories: Drupal
  1. January 17, 2011 at 1:01 PM

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

  2. Emko
    January 26, 2012 at 8:52 PM

    Yes, I’ve been looking for this answer all day.
    Thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: