3 votes

Can I set default access settings?

Looking at webform.api.php there is a specific hook for that: /** * Implements hook_webform_access_rules_alter(). */ function mymodule_webform_access_rules_alter(array &$access_rules) { if (...
4uk4's user avatar
  • 99.2k
2 votes
Accepted

Email multiple addresses from a composite element in a webform

You don't have an array of email addresses, you have an array of composite field items. So loop over the field items, build the array of emails {% set emails = [] %} {% for m in data....
4uk4's user avatar
  • 99.2k
2 votes

Query webform submissions

Remember to include accessCheck(FALSE) or you won't get any result. $query = \Drupal::entityQuery('webform_submission') ->condition('uid', $uid) ->accessCheck(FALSE); $result = $query-&...
Javi García's user avatar
2 votes

How can I debug an "access denied" on almost every webform?

The webform module alone has 11 places where it throws an access denied exception. There could be hundreds more in core, contrib or custom code. To find it the easiest way would be a debugger stopping ...
4uk4's user avatar
  • 99.2k
2 votes

Why does this Twig code not perform math operations as expected?

Use number_format(2, '.', '') to remove commas so you can perform math operations.
cilefen's user avatar
  • 5,830
2 votes

Loading webform in modal is too slow

The core team is working on cacheable Ajax requests. The first project using it is Views. Modals might be next. Until then you could deliver the hidden webform together with the cached page and unhide ...
4uk4's user avatar
  • 99.2k
1 vote
Accepted

Create a custom $form_id for a webform integrated into a node?

Setting a breakpoint in a form alter hook I see at least two ways to get the info you are looking for: $form['#webform_id'] or the base form ID (without the node details) in $form_state->...
4uk4's user avatar
  • 99.2k
1 vote
Accepted

How to alter submission data when inserting a submission

You can use hook_ENTITY_TYPE_presave() to alter webform submission data before insert: function Mymodulename_webform_submission_presave(\Drupal\webform\Entity\WebformSubmission $webform_submission){ ...
mini's user avatar
  • 802
1 vote
Accepted

Programmatically updating a Webform submission with a file element doesn't remove the attached files

This issue replicable for anonymous users only, kind of caching issue so if you add following cache API function code in custom form , then latest submission data 'll be load that 'll be added/removed ...
mini's user avatar
  • 802
1 vote

How to get the Drupal webform submission changed value?

To get webform submission data and manipulate it before the save you can use a presave hook. Hooks must be declared inside a .module file at the root of a custom module. Here's an example for your use ...
Antoine Subit's user avatar
1 vote

How to send file from React to Webform via Rest

This answer is about the REST/JSON:API in Drupal generally, and not specifically about Webform REST. To attach a file via REST/JSON:API, you need two requests: The request to add the file The request ...
Patrick Kenny's user avatar
1 vote

How can I avoid forms are saved as drafts?

There is a section called submission draft settings in the form's settings tab /admin/structure/webform/manage/<YOUR_WEBFORM_ID>/settings/submissions
Hudri's user avatar
  • 5,473
1 vote

How to set a webform default value for anonymous user?

Webform has the built-in ability to define default values for form fields when they're empty. If I remember correctly, it's in the Advanced section when you configure a field. The default value ...
Joseph's user avatar
  • 1,596
1 vote
Accepted

Webform Create node, send email when webform is submitted

Use \Drupal\webform\Entity\WebformSubmission::resave instead of \Drupal\webform\Entity\WebformSubmission::save
Vanish's user avatar
  • 166
1 vote

Define key for html email

Solved after lots of experimenting. Select 'Twig template' as the Body type in the email handler. Name your twig file as 'webform-email-message-html--WEBFORM-ID.html.twig'.
Glenn's user avatar
  • 21
1 vote
Accepted

Is there an alternative to hook_webform_submission_render_alter()?

Based on your specific use case, you can use hook_webform_element_access to hide elements.
cilefen's user avatar
  • 5,830
1 vote

Computed multiplication

You should drop the number_format altogether (not sure what the requirement is), or place it at the end of the calculation, i.e. {{ (data['license_amount'] * 0.019)|number_format(2) }} number_format ...
Stefanos Petrakis's user avatar
1 vote

How can we move Webform's progress bar from above the form to below it?

You can do it in the hook_webform_submission_form_alter. You need to unset '#weight' array key in the render element for the progress bar and move it to the appropriate place where you want it ...
Drpalouc's user avatar
1 vote

Theming webform element label template for entity checkboxes field

You should set twig.config: debug: true in your services.yml which will allow you to see the current suggestions. You should see your suggestions, however with Drupal even if you do and you passed the ...
EagleUK's user avatar
  • 151
1 vote
Accepted

Is there a simpler way to sum selected options in Webform computed_twig

I finally found a great clean solution and I hope it can save someone the frustration and hours of search and trials and reading to no avail like I did. I simply used this in my computed_twig template....
Adam888's user avatar
  • 97
1 vote

What's the point of using Webform Node instead of directly using a Webform's form?

Under the hood, when you place a webform field under a Node (or any entity really) and make a submission through that entity, the entity is recorded in the submission. If you look at the ...
Joseph's user avatar
  • 1,596
1 vote

How do you override a module's template from another module?

Thanks for this! I wanted to clean up the answer a little bit. This is essentially the same with a couple changes: Instead of creating a new theme suggestion/hook for every hook already in the system,...
maskedjellybean's user avatar
1 vote

Are there JavaScript events sent by Webform Conditionals?

I've spent a while looking at this in D9 it seems the events that are used don't get propagated which is probably why this is not documented or used elsewhere. Having tweaked the JS to emit events on ...
Jeremy French's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible