Webforms for Everyone
Jacob Rockowitz
Before we Begin ... Let's SAY "Hello!"
Prefix your questions with a "Q:"
Webforms for�EveryONe
This work is licensed under a Creative Commons Attribution 4.0 International License.
Hello!
Hi, my name is Jacob Rockowitz.
What is the
WEBFORM MODULE?
The Webform �module is a �powerful & flexible �Open Source �form builder & �submission manager �for Drupal 8
Webforms for everyone
Site�Builders
Site�Owners
Drupal�Developers
Webform for everyone
my Goal is to answer your questions...
...and show you my favorite webform things
Webform for
Site Owners
Why should you �use the Webform module?
the Webform module �allows you to �build any type of form �or application
The use case…
ONCE AGAIN, THE USE CASE…
BUILD
COLLECT
DISTRIBUTE
<demo>�Webform Basics
The �YAML Source mode�is AWesome!!!
Customizable results�table�with or without �Views
Generate�PDFs from submissions
What are some �of the features �included with the �WEbform module?
The Webform module provides all the features expected from an enterprise proprietary form builder combined with the flexibility & openness of Drupal
Webform FORM features
Every possible�confirmation message �& page �is supported
Webform Element features
There is a style-guide �which shows�every available webform element
Elements �Support �titles,�Placeholders, descriptions,�help,�& more
How do you get
support for the webform module?
Getting help
There are Videos �about every �webform�feature
InspirE you to Build awesome webforms
Questions?
What are some other webform features that �you are interested in hearing about?
Webform for�Site builderS
How DO YOU �build Awesome Webforms?
Learn from �examples & demoS
Webform Examples module
computed �twig �elements�are �awesome!!
Composite elements �are multiple elements working together
You can �even build �custom options Elements
The webform module & drupal is one of the �most accessible �form builders & content management applications on the market
What can you �build using the Webform module?
Applications
REGISTRATION
ETC. . .
College Applications
Job Applications
Employee Evaluations
Event Registrations
Meetup Registrations
User Registrations
Online Donations
Appointments
User Profiles
Webform Demos
<demo>�Webform Demo:�Event Registration
How DO YOU �SHARE your
Webforms & applications?
Sharing�Webforms
How DO YOU
Extend the
Webform module?
Install�webform �Add-ons
Extending the webform �module
Questions?
What are some of the challenges that �you are facing when building webforms?
Webform for�developers
What can you �do with the �Webform module?
Every aspect of the �webform module is�extendable & customizable�using plugins & hooks
Plugins are
small pieces of functionality that are swappable
Plugins are...
Reusable
Extendable
Standardized
Webform plugins
Elements�Wrappers that enhance Drupal form elements
Variants
Used to create and manage for A/B testing, segmentation, and personalization
Handlers
Used to route submitted data to applications and send email notifications
Exporters
Used to download submissions into spreadsheets and other applications
@see \Drupal\webform_example_composite\Element\WebformExampleComposite
class WebformExampleComposite extends WebformCompositeBase {
public function getInfo() {
return parent::getInfo() + ['#theme' => 'webform_example_composite'];
}
public static function getCompositeElements(array $element) {
$elements = [];
$elements['first_name'] = [
'#type' => 'textfield',
'#title' => t('First name'),
];
$elements['last_name'] = [
'#type' => 'textfield',
'#title' => t('Last name'),
];
return $elements;
}
}
WEBFORM HANDLERS
Email & Scheduled Email
Sends a webform submission via an email
Actions & Settings�Trigger a conditional action or setting on a submission
Remote Post
Posts webform submissions to a URL
Debug�Debug webform submission
remote post handlers �allows a webform to �be integrated with any external �API or system
A WEbform variant �is a alternate instance �of a webform That �adjusts Settings, Elements, �or behaviors to �yield a Better result
Webform Variants �make it �easy to do �a/b testing
the results download�page�use a customizable & Extendable exporter plugin
Hooks are
functions that
define or alter
behaviors
FORM hooks
hook_webform_submission_form_alter
element hooks
hook_webform_element_alter
option hooks
hook_webform_options_alter
handler hooks�hook_webform_handler_invoke_alter
entity hooks
hook_webform_submission_insert�hook_webform_submission_load�hook_webform_submission_save�hook_webform_submission_delete�etc…
more hooks…
hook_webform_libraries_info_alter�hook_webform_access_rules_alter
@see webform.api.php
What are two KEY THINGS DEVELOPERS SHOULD understand About The webform module?
The webform module �extends Drupal's FORM API �& the WEbform module's APIS �are reusable
HOW DOES DRUPAL's FORM API WORK?
BUILD
VALIDATE
SUBMIT
<?php
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('custom_module');
// Define the element(s).
$form['nodes'] = [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Select favorite articles.'),
'#multiple' => 15,
'#target_type' => 'node',
'#selection_handler' => 'default:node',
'#selection_settings' => [
'target_bundles' => ['article' => 'article'],
'sort' => ['field' => 'title', 'direction' => 'ASC'],
],
'#default_value' => $config->get('nodes'),
];
// Process the element(s).
$this->elementManager->processElement($form['nodes']);
// Attach behaviors. Unsaved: Warn users about unsaved changes.
$form['#attributes']['class'][] = 'js-webform-unsaved';
$form['#attached']['library'][] = 'webform/webform.form.unsaved';
return parent::buildForm($form, $form_state);
}
VOILA!!!�now you have a multiple entity autocomplete element
<demo>�Webform Devel:�Form API Export
Webform APIS & Features that are NOT reusable
webform APIs & features That are also reusable
Help improve APIS by contributing �code & ideas
Webform �& Drupal�getting involved
Getting involved in the Webform module
jrockowitz.com
Questions?