Other than copy and past the code from a webform, is there a way to make it a block. For example, I want a form to always be in the left column of my site and if I change the webform I would like it to update in the left column automatically rather than having to copy/paste the code from the form page to the block. Certainly not a showstopper, but I'm lazy :)

thanks

Comments

rs7272’s picture

If anyone cares, the site I'm wanting to add this to is www.lawinfonet.net - they want the form to be on the left column (with all the other business...) Again, I have done that before by copy paste, but I want them to be able to change the webform if needed and have it update in the block, not just the actual webform page.

p6’s picture

Nodeasblock Module is perhaps what you're looking for.

- p6
www.bas.org.in

- Pavan Keshavamurthy
http://grahana.net/

keylope’s picture

I tried to use nodeasblock with webform and unfortunately, the actual form doesn't display in the block form. Only the title and description.

Oh well.

davegan’s picture

Using the Views module, create a block that displays the single full node for the webform.

siliconmeadow’s picture

Using the Views module, create a block that displays the single full node for the webform.

Superb! That works a treat for me!

colincalnan’s picture

Using the Views module, create a block that displays the single full node for the webform.

Genius. I tried this and it worked superbly. I am using the Viewfield module (http://drupal.org/project/viewfield) to allow you to add a view field to a CCK content type. I have a "Page" content type which has the field, so I created a view showing just the one webform and can now include that webform on multiple node pages. Fantastic, thanks, I'd never have thought of doing that.

rupl’s picture

Creating a block View is very clever and easy, thank you for the suggestion!!

If anyone is trying to do this:

  1. Create a new View, with View type = Node
  2. Default Display » Basic Settings:
    • Style = Unformatted
    • Row style = Node
    • Items to display = 1
  3. Default Display » Filters:
    • Node: Title = [title of your webform node]
    • Node: Type = Webform
  4. Create a new Block display. Be sure to set a descriptive block name in the Block Settings
  5. Save the View, then go to the Blocks admin and place the block somewhere.
  6. Use your new block's id for all of your CSS formatting
m_i_c_h_a_e_l’s picture

Just wanted to say thanks.

Your instructions were simple and clear.

In fact, it helped me to learn a little more about Views.

Great post.

pixelpowrrr’s picture

Excellent instructions! Like MichaelBrown, in addition to working perfectly, these steps helped me understand Views more. I wasted some time trying to use the Webform Block module before using your instructions, which do the job better & don't require an extraneous module.

Oruen’s picture

Thanks!

This saved me a lot of time :)

Pentacor’s picture

What a breath of fresh air to get a simply explanation! Thanks so much I agree has made views make a little more sense aswell.

Thanks again!

rupl’s picture

I'm glad it was helpful! I wrote the post above during my first few weeks of Drupal/Views use, and unfortunately I can't edit it now.

I'd strongly recommend using a Node ID filter over Node Title/Type. Changing the webform's title will break things if the Views filter depends on it.

fdg123’s picture

I am sorry, I am a newbie and tried using views (as per Excellent Suggestion) and the block is there, BUT I only get a link to my webform node. I want the webform displayed on the page in the left side bar block (it's a contact us fast form). What am I doing wrong? sniff, sniff.
DISREGARD THIS POST - I LEARNED MORE ABOUT VIEWS AND GOT IT TO WORK.

danoprey’s picture

Thanks for sharing how!

For anyone else who had this problem, it's because views is displaying the node teaser rather than the full node. There should have been an option to change this whilst setting up the view, but if you missed it you can also fix it here:
1. Go to your web form edit page
2. Expand 'Webform advanced settings'
3. Tick 'Show complete form in teaser'
4. Save

Lendyman’s picture

Hi, I did the block that display the webform, but when this webform is fill it creates a content and not a submission to that webform. Can someone tell me what Im doing wrong?
Than

iwant2fly’s picture

There is a much simpler solution with the never versions of Webform.

Simply edit your Webform, then click the Webform > Form Setting tabs. Scroll down and expand the Advanced Settings. Check the "Available as block" checkbox. You now have your webform as a block.

Orangefox Web Developers’s picture

Don't know if this has been answered before but this is now built into webform, stumbled across it today.

When in editing webform goto:
webform -> form settings -> Advanced settings -> now "tick Available as block".

Hope this helps somone.

svn7svn’s picture

should the path be - /admin/settings/webform?

i found it once before and now i can't find it again. =-/

nevets’s picture

View the webform, there will be additional tabs for users with appropriate permissions, one will be for that webforms settings.

svn7svn’s picture

oops, i figured out my mistake. you actually have to create a webform first. duh, my bad. thanks much for the reply!

nevets’s picture

I have not used webform but there are some issues you should be aware of. The first is to see how the action is set, it normally defaults to the page being viewed and in the case of placing a form in a block this would be incorrect. Modules like the search module set the action so they will work in a block. A quick check shows action not being set by the webform module so this would be an issue.

And cutting and pasting a form will generally not work in Drupal as it does security checks to avoid unwanted postings but it generally means forms not generated with the forms API will not work. And while the original form is produced by the form API, there are parts of the form data that are dynamic and "expire" after a certain amount of time.

rs7272’s picture

After I make or update the webform, I can view source and copy / paste it in a block and it works fine, but they want to be able to update the webform and have it be updated in the block too without having to copy paste - it will be rare if ever that they make changes anyway...

arbel’s picture

The views solution works, I'm using it now, and that's the only way I managed to work around that bug.

Idan

chris_d_adams’s picture

I just wish I found this two weeks ago...

enlighten_me’s picture

Views thus far in Drupal 6.x show the teaser, but not the form part itself. Any workarounds?

dgoldenbaum’s picture

You might need to change Basic Settings / Row style: Node / settings = Node (instead of teaser)

Pratheep’s picture

Thanks mate. This really helped for me

Schoonzie’s picture

I created a new block with the input format as PHP and used this code to get it to work:

print node_view(node_load($nid), $teaser = FALSE, $page = FALSE, $links = TRUE);
yumminy’s picture

Worked well for me, thanks!

e3ekiel’s picture

Would you be able to tell me how you set up views to show webform? I've tried but can't manage to do it.

Also can you set up a view to show the node how it actually looks as it seems to unformat everything?

Thanks

e3ekiel’s picture

ignore me worked it out!

rmassamiri’s picture

Could you tell me exactly how you worked it out? I'm new to drupal and views and it's not making sense to me. I'm using Drupal 6 and webforms. I'm trying to get a specific webform to show up in the sidebar as a block using views. Is there a simple way to do this without using code? Thanks, Rani

sambkk’s picture

look at the post titled excellent suggestion, thats very clear on how you get your form displaying in using views, just make sure you add display "block", then you just go over to administer -blocks and place the block (which will show up on the list of blocks now) where you need it.
styling may be a different issue alltogether, I havent gotten that far yet

petergrob’s picture

You can also use the module webformblock.

El Bandito’s picture

Does anyone have a view ( no pun intended ) on whether the webformblock or Views approach is preferable. My site already has Views installed ? Any pro's or con's ?

Cheers

Dave

OldAccount’s picture

Duh, create a Views block, of course! Thanks davegan for suggesting that, and to rupl for giving the step-by-step. I knew there was an easy answer.

FYI, make sure you select "Show complete form in teaser" in Webform Advanced Settings or you'll just see "Go to form" in your block.

Score one more for Views -- I avoided installing another module.

DrDaveExeter’s picture

Using a Views Block is not working for me, sorry to say: the text is there but the form elements are missing.
Can anyone please advise on what's wrong with this exported View?

$view = new view; $view->name = 'sign_up_block'; $view->description = 'Sign Up block'; $view->tag = ''; $view->view_php = ''; $view->base_table = 'node'; $view->is_cacheable = FALSE; $view->api_version = 2; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ $handler = $view->new_display('default', 'Defaults', 'default'); $handler->override_option('fields', array( 'body' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'exclude' => 0, 'id' => 'body', 'table' => 'node_revisions', 'field' => 'body', 'relationship' => 'none', ), )); $handler->override_option('filters', array( 'nid' => array( 'operator' => '=', 'value' => array( 'value' => '13012', 'min' => '', 'max' => '', ), 'group' => '0', 'exposed' => FALSE, 'expose' => array( 'operator' => FALSE, 'label' => '', ), 'id' => 'nid', 'table' => 'node', 'field' => 'nid', 'relationship' => 'none', ), )); $handler->override_option('access', array( 'type' => 'none', )); $handler->override_option('cache', array( 'type' => 'none', )); $handler->override_option('items_per_page', 1); $handler = $view->new_display('block', 'Block', 'block_1'); $handler->override_option('block_description', ''); $handler->override_option('block_caching', -1);

nevets’s picture

The webform module now has an option to expose the form in a block.

druvision’s picture

Don't use the Webform block module - it's not updated fast enough and it's not compatible with the latest D6 webform version. The views solution is preferable.

arbel’s picture

Has anyone got this to work with ajax? I've installed the ajax module, activated the webform ajax module, and activated the content type in the settings, but it still doesn't work work while in a block.

Thanks

Idan

honigferd’s picture

Fighting with the same problem right now. :-S

jack_vanlommel’s picture

Hi all,

does anyone have any idea how to prevent error messages being displayed in the main content div?
I want to display them within the block self.

When I submit the form in the block and let the fields blank... the form itself opens in the main div with error messages.

THX in advance
greetz
jack vanlommel

creativeideas’s picture

hi jack

fighting with the same problem do u get the answer of this query.....

code-brighton’s picture

Hi Jack, I had the same issue, which is a shame as I would rather use the Views solution than install another module. But as others have found Webform Block worked for me:
Webform Block:
http://drupal.org/project/webformblock

russdawgbass’s picture

I was having trouble with this in a situation where I wanted to reuse a single webform in two sections of our site. Our node id was node/21, but the page url(s) I wanted the form located on was called residential/contact and commercial/contact. These both worked fine until a user tried to submit the form and there were validation errors, the form would submit to the node breaking the design around the form. After fiddling around with the view solution mentioned here and still seeing the same issues, I resorted to the following code to change the form action to match the page url. Easy, simple, clean.

I created a file called behavior.js and put it in the theme's root folder.

In my theme's .info file, I placed a reference to behavior.js:
scripts[] = script.js => This is the orginal line.
scripts[] = behavior.js => This is the addition.

Then the code in behavior.js was 5 simple lines.

Drupal.behaviors.setWebFormAction = function (context) {
	if ($("#webform-client-form-21").length > 0) {
		$("#webform-client-form-21").attr("action", window.location.pathname);
	}
}

However, when the form is submitted successfully, it loses page context again. Does anyone know exactly which file I would need to put in my theme folder to override the form redirecting back to the node when the form processing completes and instead redirect back to the page url the form was placed on?

Note: I'm using Drupal 6.16, Webform 6.x-3.0-beta5 and Nodes in block 6.x-1.5 to get the form to show up on multiple pages.

jschulz-1’s picture

Hi Russell,

If you don't mind putting a PHP snippet into the Webform Redirect URL field, you can use something like this:


$ref = getenv("HTTP_REFERER"); 

drupal_set_message('Thanks a lot!', 'status');

drupal_goto($ref);

Of course, you could also put this code in a module and use hook_form_alter to achieve this.

iwant2fly’s picture

Thanks for the great answers.

Anonymous’s picture

I've been looking for a solution to this for months. Fortunately, I just found an amazing new module which solves this problem!

Webform Block:
http://drupal.org/project/webformblock

gotosachin18@gmail.com’s picture

yeah...it can. just visit the webform advance settings and see for block option. enable it and u have done what u want...now webform will appear in blocks.

Zonbizoku’s picture

Can confirm, in recent versions on webform, forms are available to be displayed in a block from within that webform's settings:

Visit webform > Hit 'Webform' tab in edit menu > Form Settings > Advanced Settings > tick checkbox next to 'Available as block'.
Relevant block should now appear in 'disabled' area of block configuration page.