Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

my_module.module: /** * Implementation of hook_theme * * Since we have a lot to explain, we're going to use Twig to do it. */ function my_module_forms_theme($existing, $type, $theme, $path) { return [ 'my_template' => [ 'template' => 'my-template', 'variables' => ['form' => NULL], ], ]; }


0

When I grab the submission data I get "1" This is standard in Drupal for select & radio fields, you always get the key. So all we have to do is use the key to retrieve the value. $key = $webform_submission->getData()['field_select']; // retrieve webform fields. $webform_fields = $webform_submission->getWebform()->getElementsDecoded(); // ...


0

Could someone please tell me what key thing(s) I need to do to make that connection There are 4 ways that you can tell Drupal that your plugin exists. You can read about the other 3 at D8 Plugin discovery In this case Webform uses: AnnotatedClassDiscovery The AnnotatedClassDiscovery class uses name of the annotations that contains the plugin ...


0

See this issue. In the comments, it shows that there is a function called _webform_share_eval() in the webform_share.module file. function _webform_share_eval($str) { eval($str); return empty($webform) ? FALSE : $webform; } It's very simple to use this to import a webform and save a node. // Create the node $node = new stdClass(); $node->type = '...


0

I have found an answer here: https://www.drupal.org/project/webform/issues/3046808 if ($source_entity = $webform_submission->getSourceEntity()) { $nid = $source_entity->id(); } else { $nid = NULL; }


0

You can switch the Webform's HTML Editor to any 'Text format' which are fully customizable. @see /admin/structure/webform/config/elements


0

you have to do it inside the form_id 'form_builder_field_configure'. Example : hook_form_alter($form,$form_state,$form_id){ `switch($form_id){ case 'form_builder_field_configure': // You put your code here $form['check'] = array( '#form_builder' => array( 'property_group' => 'validation' ), '#type' => '...


0

I had this same issue, what worked for me was under webform settings > Confirmation > Confirmation Type. Change the confirmation type to 'Inline (reloads the current page and replaces the webform with the confirmation message)' This returned true for $event->getResponse()->getWebformSubmission()->isCompleted()


0

Later I realised that I need to run a custom php code, so I wrote this, which actually works: // use the submitted time value from the webform and convert it to time, also use it for an end date one year later $time = strtotime($data['components']['submitted time']['value'][0]); $time2 = strtotime('+1 year', $time); //convert to date formats to the format ...


2

You can do it in a custom module using entity.query service $query = $this->entityTypeManager()->getStorage('webform')->getQuery(); $webform_ids = $query->condition('status', 'open')->execute(); $webforms = Webform::loadMultiple($webform_ids); $webform_urls = []; foreach($webforms as $webform){ $webform_urls[] = $webform->toUrl()->...


0

I'm doing something similar to the above request using a computed twig. Make sure "automatically update the computed value using Ajax?" is checked, and then enter this in the computed value / markup section of the computed twig; {{ data.weight * data.number_of_packages }} this follows the syntax {{ data.element_key * data.element_key }} This might work ...


0

Make sure that the webform's source entity id can be prepopulated via a URL and the below code should work using $source_entity->id() instead of $source_entity->id /** @var \Drupal\webform\WebformRequestInterface $request_handler */ $request_handler = \Drupal::service('webform.request'); $source_entity = $request_handler->getCurrentSourceEntity('...


0

For that you may have to create handler and activate that handler after the webform submission, get the keys as a simple text field perform the hash operation on it and then save to database. webform supports this -


2

You always need to load before delete, there is no "better" solution. I am affraid from affecting the performance of the website since the above handler will be executed a lot Loading one entity at a time is no performance issue whatsoever. $webform_submission = \Drupal\webform\Entity\WebformSubmission::load($sid); // Check if submission is returned. ...


Top 50 recent answers are included