Assuming the webform exists as node XXX, would

<?php print drupal_get_form('webform_client_form_XXX') ?>

bring it up?

I am getting

warning: Missing argument 1 for webform_client_form() in /home/content/a/n/s/answerjam/html/test/sites/all/modules/webform/webform.module on line 1210.

Comments

andrabr’s picture

The following seems to work Ok:

$node = node_build_content(node_load(XXX));
print drupal_render($node->content);
quicksketch’s picture

You have to pass in all the form parameters. I've included them all here as variables for a clear example.

  $submission = array();
  $enabled = TRUE;
  $preview = FALSE;
  print drupal_get_form('webform_client_form_XXX', $node, $submission, $enabled, $preview);
andrabr’s picture

Thank you!
Since drupal_get_form is poorly documented, let me try to impose on your patience once again:

In your example,
1) where does the value of $node come from?
2) What is the purpose of $submission? does it need to be pre-populated?
3) What is $enabled for?

I do not mean to hog your time, but i have searched and searched and found only questions. A couple of relevant links would go a long way (yes, i have been reading up on Forms API, but failed to find the answer)

Many thanks in advance

Andrey

quicksketch’s picture

You should read the PHP Doc for webform_client_form() where each of the parameters is documented (or should be :P). We probably could set defaults for most of the parameters, but I haven't seen many people calling drupal_get_form() to get a webform directly.

The $node object is the node containing the webform. If you don't have it already you can load the webform like this:

  $node = node_load($nid);
andrabr’s picture

Status: Active » Closed (fixed)

Thx!

rv0’s picture

Version: 5.x-1.9 » 7.x-3.x-dev

In drupal 7

  $submission = array();
  $enabled = TRUE;
  $preview = FALSE;
  print drupal_get_form('webform_client_form_XXX', $node, $submission, $enabled, $preview);

did not work

  $submission = (object) array();
  $enabled = TRUE;
  $preview = FALSE;
  print drupal_get_form('webform_client_form_XXX', $node, $submission, $enabled, $preview);

this does...

goldhat’s picture

Is there any advantage to this rather than making the Webform available as a block, and then embedding the block in your node template?

rv0’s picture

@goldhat
in my case i needed the webform in a ctools modal frame.
was "easier" this way.

dobe’s picture

In drupal 6 this is what worked for me:

Where XXX is the node id.

<?php 
$webform = webform_block_view($delta = 'client-block-XXX');
print $webform['content']; 
?>
waspper’s picture

... And works Ok on Drupal 7

SimonRain’s picture

I have a solution that outputs the same html as working example in your post @rv()

I was working on a similar problem but I had to return the form in a JSON object to be displayed in a web app.

$node = node_load($node_id);
webform_node_view($node,'full');
$node_rendered = theme_webform_view($node->content);

then you can print the $node_rendered or return it inside of a JSON object

asauterChicago’s picture

Old posts, but this comes up high in Google. So if anyone else is looking to embed a webform in views on Drupal 7, number 9 actually works in getting the form to pull up in a views footer. I tried all the other posts in here and post #9 in here was the only one that worked.

prsnjtbarman’s picture

Issue summary: View changes
$node = node_build_content(node_load(10));
$submission = array();
$enabled = TRUE;
$preview = FALSE;
        
drupal_get_form('webform_client_form_10', $node, $submission, $enabled, $preview);
Marc DeLay’s picture

You don't need the submission or enabled parts, In fact those are no longer the proper arguments for the function. (In this case they won't really hurt anything, but it will add confusion.)

<?php
$node = node_build_content(node_load(10));
$node_webform = drupal_get_form('webform_client_form_10', $node);
drupal_render($node_webform);
?>
aegirone’s picture

#14 It doesn't work :( .