Greetings,

How does one pre-fill a field in a webform, with the title of a page node?

If the default value in webform, is '%get[title]'.

Do I access the webform using
1) mysite/node/3?title=value OR
2) /node/3?title= echo $title;

Appreciate some help here.

lilyvaly

Comments

nancydru’s picture

I'm wondering if you're ready to do forms if you don't know this. All form fields have a "default_value".

  $form['Display']['items_per_page'] = array(
    '#type' => 'textfield',
    '#title' => t('Items per page'),
    '#size' => 5,
    '#maxlength' => 5,
    '#prefix' => '<div class="pinkslip_boxes"><div class="pinkslip_3_cols">',
    '#suffix' => '</div>',
    '#description' => t("This sets the number of items that will be displayed on a page."),
    '#default_value' => variable_get('pinkslip_items_per_page', 10)
    );

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

lilyvaly’s picture

I am using the webforms module. And I am able to add default values of username and email. So I would say that I am aware that one of the properties of the field object in a form, is a default value.

So in that aspect, I am asking the above question, of how I can pass the value of the title of the page node to another webform, to be displayed(i.e defaulted) in a specific field.

More simply put, how do I access the 'title' property of the page node? Is it with 'page.title'? Am I missing some syntax, to pass the title value to the webform? I have tried to pass other hard-coded values to the webform, and it seems to work.

Do hope that it is clearer..

nancydru’s picture

This gets the title of the active page.

  $title = drupal_get_title(); 

To generically get the title of any page (or story, etc.)

  $node = node_load(xxx);   /* xxx is the node ID */
  $title = $node->title;

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

lilyvaly’s picture

Will try it out soon.