Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
andrabr CreditAttribution: andrabr commentedThe following seems to work Ok:
Comment #2
quicksketchYou have to pass in all the form parameters. I've included them all here as variables for a clear example.
Comment #3
andrabr CreditAttribution: andrabr commentedThank 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
Comment #4
quicksketchYou 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:
Comment #5
andrabr CreditAttribution: andrabr commentedThx!
Comment #6
rv0 CreditAttribution: rv0 commentedIn drupal 7
did not work
this does...
Comment #7
goldhat CreditAttribution: goldhat commentedIs there any advantage to this rather than making the Webform available as a block, and then embedding the block in your node template?
Comment #8
rv0 CreditAttribution: rv0 commented@goldhat
in my case i needed the webform in a ctools modal frame.
was "easier" this way.
Comment #9
dobe CreditAttribution: dobe commentedIn drupal 6 this is what worked for me:
Where XXX is the node id.
Comment #10
waspper CreditAttribution: waspper commented... And works Ok on Drupal 7
Comment #11
SimonRain CreditAttribution: SimonRain commentedI 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.
then you can print the
$node_rendered
or return it inside of a JSON objectComment #12
asauterChicago CreditAttribution: asauterChicago commentedOld 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.
Comment #13
prsnjtbarman CreditAttribution: prsnjtbarman commentedComment #14
Marc DeLay CreditAttribution: Marc DeLay as a volunteer commentedYou 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.)
Comment #15
aegirone CreditAttribution: aegirone commented#14 It doesn't work :( .