0

Webform custom handler is not showing in DEV server but it works in local.It makes very difficult to save additional information.


namespace Drupal\demo_module_dym\Plugin\WebFormHandler;


use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Form submission handler.
 *
 * @WebformHandler(
 *     id = "demo_module_dym_registration_submission_handler",
 *     label = @Translation("Registration form handler"),
 *     category = @Translation("API"),
 *     description = @Translation("Set User Information on hidden field before submit form."),
 *     cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *     results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */
class RegistrationFormHandler extends WebformHandlerBase {


  public function preprocessConfirmation(array &$variables) {
    parent::preprocessConfirmation($variables); // TODO: Change the autogenerated stub
  }

  public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

    if (\Drupal::currentUser()->isAnonymous()){

      $memberid = $form_state->getTemporaryValue('memberid');

      if (isset($memberid)){
        $webform_submission->setElementData('memberid', $memberid);
      }

    }
    parent::submitForm($form, $form_state, $webform_submission); // TODO: Change the autogenerated stub
  }

}


Is there way to debug to find the cause webform handler not showing in handler list on sever?

  • Have you cleared cache ? What is different between servers ? perhaps a different theme ? any different modules ? start with seeing the differences. You might want to create the exact duplicate (or as much as possible) of the live server before you can properly debug it. – GiorgosK Mar 20 at 9:34
  • Thanks for response, everything is same and clear several times it didn't work. After, I change the folder name from "WebFormHandler" to "WebformHandler" and add constructor on RegistrationFormHandler. It shows on handler list but it couldn't add the handler from email/handler setting. Then, I removed the Telephone field and clear the cache and it added on the Form. I get constantly php error message : Notice: Undefined index: description in webform_token_info_alter() (line 396 of modules/contrib/webform/webform.module). webform_token_info_alter(Array, NULL, NULL) (Line: 539). – Bhagi Raj Limbu Mar 20 at 13:23
  • It does not ? does it show any message as to why it does not ? does the logs have any relevant entry ? – GiorgosK Mar 20 at 13:24
  • I monitor log it does not shows web form handler message. I used to get a php error message : Notice: Undefined index: description in webform_token_info_alter() (line 396 of modules/contrib/webform/webform.module). webform_token_info_alter(Array, NULL, NULL) (Line: 539) I believe it cause by Telephone field – Bhagi Raj Limbu Mar 20 at 13:28
  • The error Undefined index: description in webform_token_info_alter() (line 396) may have been fixed in the latest dev release of the Webform module. – jrockowitz Mar 20 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.