Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. namespace Drupaldemo_module_dymPluginWebFormHandler;
  2.  
  3.  
  4. use DrupalCoreFormFormStateInterface;
  5. use DrupalwebformPluginWebformHandlerBase;
  6. use DrupalwebformWebformSubmissionInterface;
  7.  
  8. /**
  9. * Form submission handler.
  10. *
  11. * @WebformHandler(
  12. * id = "demo_module_dym_registration_submission_handler",
  13. * label = @Translation("Registration form handler"),
  14. * category = @Translation("API"),
  15. * description = @Translation("Set User Information on hidden field before submit form."),
  16. * cardinality = DrupalwebformPluginWebformHandlerInterface::CARDINALITY_SINGLE,
  17. * results = DrupalwebformPluginWebformHandlerInterface::RESULTS_PROCESSED,
  18. * )
  19. */
  20. class RegistrationFormHandler extends WebformHandlerBase {
  21.  
  22.  
  23. public function preprocessConfirmation(array &$variables) {
  24. parent::preprocessConfirmation($variables); // TODO: Change the autogenerated stub
  25. }
  26.  
  27. public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
  28.  
  29. if (Drupal::currentUser()->isAnonymous()){
  30.  
  31. $memberid = $form_state->getTemporaryValue('memberid');
  32.  
  33. if (isset($memberid)){
  34. $webform_submission->setElementData('memberid', $memberid);
  35. }
  36.  
  37. }
  38. parent::submitForm($form, $form_state, $webform_submission); // TODO: Change the autogenerated stub
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement