Building Conditional Webforms in Drupal 7
One of our OSTraining members asked us how to configure webforms with conditions and we prepared for you this tutorial to show you how you can do just that.
For this tutorial, you will need the following Drupal modules:
Once you downloaded the, please go to modules are make sure you have enabled them.
You should have the following module options ticked:
- Chaos tools
- Form builder
- Form builder Webform UI
- Token
- Options element
- Views
- Views UI.
Under Structure > Content types, you will see that you now have the 'Webform' content type. Review the default settings of this content type. I personally removed the "Published By" but this is my own personal preference.
Now that we have everything installed, let's start building our webform.
Go to Content > Add Content and select the Webform. We need to give this form a title and for ease of access I am also going to assign it a menu link.
Now, using the form builder GUI, you can easily drag and drop the configuration elements that we need for this webform.
I have created a feedback form that will be asking for Name, Email and to rate a service.
We want to set up a condition, which will then trigger a feedback textarea if 'Not Happy' option is selected. We want this textarea to display on the same page, so we will not use a page break for this form element.
As we now have configured our webform, let's make sure it works. While 'Very Happy' is set, you do not see the feedback textarea field:
If, however, you select 'Not happy option', to record a feedback from the user, then right away its corresponding textarea field will show up.
As you have now learned in this tutorials, using conditionals in Dripal, you can add many complex responses to your webforms, add some cool features to them and collect all the information you need.
Still have questions? Please submit them in the comments below.