I have an article on my Drupal site and need to add some calculations to it (to better illustrate a topic). It means, three textfield inputs and a button, after clicking the button a calculation should take place on server side (not in javascript, because I want this calculation to be in php on server side) and then comments should be displayed below the textfields.

The problem is, I would like to have all of it inside node, not below it - for better user experience.

Inserting input and submit button via wysiwyg works fine. Then, I need to use raw jquery ajax command and do everything manually - it should be possible.

So before doing this, I'd like to ask if there is a simpler way?

E.g. ajaxifying webform is documented. So, if the whole webform could be treated as one token, it could be inserted into wysiwyg using token filter inside node content. But webform as a token? - can't find such solution.

1 Answer 1


Build your webform, or Form api form, grab its ID and then follow my answer to insert this form into node's content through a custom module of yours

Cleaner way to do it.

  • Ok, but how to display it inside content? I.e. exactly after one paragraph and before another paragraph? I think with hook_node_view you can display it either before or after body.
    – camcam
    Commented Feb 25, 2013 at 11:18
  • you could write php in the editor i guess and render the form wherever you like (between the paragraphs). if you need a quick and dirty way go with jQuery append() or something ...
    – Pan Chrono
    Commented Feb 25, 2013 at 11:21
  • You need to create a node.tpl.php file and then render the webform before the comments inside the node.tpl.php Commented Feb 25, 2013 at 19:25

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.