Skip to main content
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
  • 100k
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
  • 100k
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

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
  • 100k
1 vote

Cannot find file input

To enable file inputs for webform, you have two options: Enable Allow files to be uploaded to public file system in the elements configuration on /admin/structure/webform/config/elements. Uploaded ...
berramou's user avatar
  • 7,245
1 vote

Entity Checkboxes: How to have one value displayed in form but another value in preview and submission?

I figured it out :-) I added a new field to the node "Short name" and to the reffered view and hid the title from display. In Advanced Tab: Submission display: show "Label" - it ...
Hans Gustavsson's user avatar
1 vote

Adding price values in webform with Twig

It seems that the issue lies in the way the prices are added to the total_price variable. The prices are being concatenated as strings rather than being summed up as numbers. To correct this, we need ...
havingaguess's user avatar
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
  • 100k
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_poojasharma's user avatar
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_poojasharma's user avatar
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,539
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,598
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
  • 146
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.
mona lisa's user avatar
  • 5,929
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

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

How can the Webform element Form display defaults be set?

Per Webform maintainer Jacob Rockowitz: In your theme or module you can create a hook_preprocess_form_element() which overrides the default #title_display set via template_preprocess_form_element(). @...
mlncn's user avatar
  • 1,482

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