5

I would like create a webform and add to content type. so when user create node, webform automatially add to node (webform is same for per node of content type).

is this feasible with webform 3?

4
  • 1 problem here. You will have 2 forms on the page (with 2 save buttons). It would be hard to get both submitted at the same time
    – iStryker
    Commented Jul 16, 2011 at 13:01
  • which page has 2 forms?
    – user780
    Commented Jul 17, 2011 at 21:44
  • which page has 2 forms with 2 buttons?
    – user780
    Commented Jul 18, 2011 at 4:44
  • This question is not clear enough to receive a useful answer. I'd edit it to make it clearer, except I don't understand it either. Please try to reword it. Commented Apr 3, 2013 at 13:43

3 Answers 3

5

You can do it by node reference. Add those kind of field to your content type. You can always set default value for automatic add webform to node, but it doesn't add you form automatically to node edit form.

I test it by using node reference and views, but it doesn't display a webform on node edit page (in the same form).

You can try to use hook_from_alter, which means to add programatically fields from reference webform. IMO is the only solution or maybe there are some modules for this, but I didn't look for them.

You need add your submit function to this form too, because you need to filter and save webform fields programatically too. Check WebForm API for this. A lot of work, maybe you should think about better solution without programming and using webform at all?

5
  • 1
    You need this module: drupal.org/project/noderelationships, then you can add node reference field to content type
    – Codium
    Commented Jul 16, 2011 at 12:29
  • this is not feasible by using just webform?
    – user780
    Commented Jul 16, 2011 at 12:32
  • Maintenance status in unknown for this module
    – user780
    Commented Jul 16, 2011 at 12:33
  • Sorry, my mistake I mean Node Reference ofcourse
    – Codium
    Commented Jul 16, 2011 at 13:37
  • link is drupal.org/project/references Commented Nov 26, 2011 at 8:26
3

I just came across this when searching for a similar thing. There are of course many ways to achieve this, and it also depends a little bit what is actually desired for a given use case. With this I mean whether a new webform should be attached to each node, or if the same webform should be shown on each of the node pages.

If you want to actually attach a new webform to each of the nodes, then you can enable webforms on that content type (from Configuration > Webform settings). This allows to create a form per node on that content type, but it does not create the form for each node automatically, it has to be created per node. This is not really useful if you want the same form for each node, but if you want the form to be created automatically, then there are a few modules to help with that: https://drupal.org/project/webform_template and https://drupal.org/project/webform_default_fields

The other approach is to create one webform and show that form on each of the node pages. This can be achieved by showing the webform as a block and specifying the block to display in the Content region and only on certain content type. First enable using a webform as a block by editing an existing webform node, click to Webform tab, click Form settings, open Advanced settings and check the Available as block checkbox. After that you can add the block from Blocks page normally and restrict visibility to a certain content type for example. If you need access to some values from the node where the form is displayed in the webform, you can add them as hidden fields and create a custom module that gets them from the node and sets the values to the form. Here is some discussion and examples about this: https://drupal.org/node/1470748

0

You can try to use hook_from_alter, which means to add programatically fields from reference webform. IMO is the only solution but what is IMO .

1
  • IMO = in my opinion
    – Imanelek
    Commented Aug 6, 2016 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.