Skip to content
Snippets Groups Projects
Commit 72930573 authored by Andrey Vitushkin's avatar Andrey Vitushkin
Browse files

Issue #3289440 by rahul17, AbhinavK: Automated Drupal 10 compatibility fixes

parent afaa1c20
Branches 2.x
Tags 2.5.0
No related merge requests found
D R U P A L M O D U L E
......@@ -6,7 +6,7 @@
_o__o_
/\ /\
____________RULES WEBFORM____________
| | | |
| | | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -14,15 +14,15 @@ ____________RULES WEBFORM____________
INTRODUCTION
------------
The 'Rules Webform' module provides integration of 'Rules' and 'Webform' modules
for Drupal 9. It enables site builders and administrators to get access to
webform submission data from rules. Also it provides possibility of altering and
removing webform submissions from rules.
for Drupal 9/10. It enables site builders and administrators to get access to
webform submission data from rules. Also, it provides possibility of altering
and removing webform submissions from rules.
INSTALLATION
------------
Install as you would normally install a contributed Drupal module. For further
information visit:
https://www.drupal.org/docs/8/extending-drupal-8/installing-drupal-8-modules
https://www.drupal.org/docs/extending-drupal/installing-modules
HOW TO USE
......@@ -43,9 +43,9 @@ additional information like submission date, author and so on.
To investigate them it's conveniently to use 'Data selection mode'. Therefore
click on 'Switch to data selection mode' button in your condition or action
page. Then type variable name with dot at the end, like this: 'webform_fields.'
After that you will see all webform fields and you can choose any of them.
After that you will see all webform fields and you can choose any of them.
But you can also use 'Direct input mode'. For instance, if you need to get the
value of 'message' field you can use Twig syntax like this:
value of 'message' field you can use Twig syntax like this:
{{ webform_fields.message }}
----------------------------
......@@ -73,7 +73,7 @@ Sir {{ webform_field.name }}
Delete a webform submission
-----------------------------
To delete a webform submission from a rule use 'Delete webform submission'
To delete a webform submission from a rule use 'Delete webform submission'
action.
KNOWN ISSUES
......
{
"name": "drupal/rules_webform",
"description": "Allows to use Webform submission data in Rules.",
"type": "drupal-module",
"license": "GPL-2.0-or-later",
"minimum-stability": "dev",
"homepage": "https://drupal.org/project/rules_webform",
"authors": [
{
"name": "Andrey Vitushkin (wombatbuddy)",
"homepage": "https://www.drupal.org/u/wombatbuddy",
"role": "Maintainer"
}
],
"support": {
"issues": "https://www.drupal.org/project/issues/rules_webform",
"source": "https://git.drupalcode.org/project/rules_webform",
"docs": "https://www.drupal.org/project/rules_webform"
},
"require": {
"drupal/core": "^9.4 || ^10",
"drupal/rules": "8.x-3.x-dev",
"drupal/webform": "^6.2"
}
}
/**
* @file
* Display select 'webform_id' element if 'webform submit' event has been
* selected. (The 'webform_id' select element is initialy hidden in the
* 'rules_webform.module').
*/
(($, Drupal) => {
Drupal.behaviors.rulesWebform = {
attach(context) {
$(context).find('#edit-events-0-event-name').once().each((i, obj) => {
$(obj).change(() => {
// Events supported by the module.
var webform_events = [
'webform_submit',
'updating_submission',
'deleting_submission',
'viewing_submission',
];
if (webform_events.includes(obj.value)) {
$("[for='edit-webform-id']").show(1);
$('#edit-webform-id').show(1);
$("[for='edit-webform-id']").addClass('js-form-required form-required');
$('#edit-webform-id').attr('required', 'required');
$('#edit-webform-id').attr('aria-required', true);
}
else {
$("[for='edit-webform-id']").hide(1);
$('#edit-webform-id').hide(1);
$('#edit-webform-id').removeAttr('required');
$('#edit-webform-id').removeAttr('aria-required');
}
});
});
},
};
})(jQuery, Drupal);
......@@ -5,10 +5,10 @@
* 'rules_webform.module').
*/
(function ($, Drupal) {
(function ($, Drupal, once) {
Drupal.behaviors.rulesWebform = {
attach: function (context) {
$(context).find('#edit-events-0-event-name').once().each(function () {
$(once('#edit-events-0-event-name', context)).find('#edit-events-0-event-name').each(function () {
$(this).change(function () {
// Events supported by the module.
var webform_events = [
......@@ -35,4 +35,4 @@
});
}
};
})(jQuery, Drupal);
})(jQuery, Drupal, once);
name: 'Rules Webform'
type: module
description: 'Allows to use Webform submission data in Rules.'
core_version_requirement: ^9
core_version_requirement: ^9.4 || ^10
package: 'Rules'
dependencies:
- rules:rules
......
......@@ -5,3 +5,4 @@ rules_webform.select_webform_id:
dependencies:
- core/jquery
- core/drupal
- core/once
......@@ -369,7 +369,7 @@ function rules_webform_extract_composite_elements(array $elements, array &$field
else {
// Exclude wizard pages and buttons from the list of elements.
if (($options['#type'] != 'webform_wizard_page') && ($options['#type'] != "webform_actions")) {
$fields_definitions[$name] = (string) isset($options['#title']) ? $options['#title'] : '';
$fields_definitions[$name] = (string) $options['#title'] ?? '';
}
}
}
......
......@@ -85,7 +85,7 @@ class RulesWebformEventBase extends Event {
else {
// Exclude wizard pages and buttons from the list of elements.
if (($options['#type'] != 'webform_wizard_page') && ($options['#type'] != "webform_actions")) {
$fields_definitions[$name] = (string) isset($options['#title']) ? $options['#title'] : '';
$fields_definitions[$name] = (string) $options['#title'] ?? '';
// If a user will submit an empty webform which contents composite
// element, then value of this element can be 'NULL'.
// Therefore prefill the array of webform_fields to prevent error
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment