Webform 8.x-5.x: How to track a webform submission's geolocation [VIDEO]

How to track a webform submission's geolocation

Problem

I would like to track where a form is being submitted from using the web browser's geolocation.

Solution

Create a hidden location element that tracks the user's geolocation as the default value.

Configurable behavior objects with @CfrPlugin

https://www.drupal.org/project/cfr
https://www.youtube.com/watch?time_continue=1&v=AejsIbZO2MI

The "Configurator plugin API (cfr)" is an API for "configuration-born behavior objects".
In site building it does take a similar, but more flexible and powerful role as the Drupal 8 plugin API or the CTools plugin API.

Webform 8.x-5.x: How to programmatically alter destination email address

You can alter the destination (to) address by adding a WebformHandler plugin. You can for example extend the EmailWebformHandler and add your own custom logic. This example changes the recipient based on the site's language:

The location of this file would be my_module/src/Plugin/WebformHandler/MyEmailWebformHandler.php

Webform 8.x-5.x: How to enable the Webform test modules

The Webform 8.x-5.x modules ships with several test modules that contain dozens of example forms that are used for automated testing and can also be used for debugging issues.

To enable the test modules, you can add$settings['extension_discovery_scan_tests'] = TRUE; to your settings.php file or you can enable the the default local.settings.php file that comes with Drupal 8.

Below is a screenshot of the available test forms.

Pages

Subscribe with RSS Subscribe to RSS - No known problems