7

In drupal 7 we used to attach a webform to nodes and then we could render them as a block, nowadays in drupal 8 Webform is a dependent entity and is designed and developed on its own. now my question is :

I've created a webform and now I want to place it in a block so user can simply fill it up in front page, How can I show a webform as a Block?

1
  • 7
    By default, Webform block will be available in the block layout, once you created the webform, Just place the webform block in the any region. and then configure it and choose the particular webform which you created – logeshvaran Feb 1 '18 at 7:30
13

Special thanks to Peacog Web Development for their great tutorial .Here is the tip:

Rather than Drupal 7, Different Block types can be created by admin

so the solution is simple :

  • Create a new block type using : admin/structure/block/block-content/types
  • Add a Reference of type Webform to custom block type
  • remove body if it's inappropriate
  • modify custom block Manage Display so the form would be rendered as webform
  • your new Block type is ready

now to add any new webform as block you, you will need to add new block of type Custom Block and refer to your webform, and that's done.

1
  • Using this method allowed me to embed this into a node using Entity Embed, which I couldn't do otherwise. – Keven Jul 16 '19 at 19:30
9

logeshvaran is correct: Webform for Drupal 8 already provides a block that can reference a webform. So no need to create a custom block type.

2
  • 2
    Make sure to search for "Webform" when placing the blocks, and then choose the Webform name in the dialog box provided. I've been searching for the name of the webform, that's why I couldn't find the block to place. – Randell Jun 7 '19 at 1:12
  • 1
    Thank you @Randell! To expound on his comment. The Block name is "Webform" and the Category is "Webform". After you select that block you will be able to choose which webform you want. – Keven Jul 16 '19 at 18:13
4

From Drupal 8 admin

  1. Create your webform
  2. Structure => Block Layout => click "Place Block" under your preferred region
  3. Find Webform then => Place Block => under Webform type your webform title and it will find it
  4. Save Block

You are all set

1
  • 1
    Thanks @hzak for this straight-forward and step by step answer! Very useful, and quick to follow. – jaesperanza Mar 26 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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