0

I'm building a multi page webform in Drupal 8 as shown below

(1) Consent to ask questions >>> (2) Chekcing eligiblity >>> (3) Consent to Participate >>> (4) Base line info >>> (5) Complete

multipage webform

In the 2nd page (Checking eligibility) as soon as the user clicks on Next Page > button, I need to validate the submitted values (which contains several radio buttons) and assess the user whether he is eligible to participate in a survey or not.

/*
 * hook_form_FORM_ID_alter()
 */
function webform_form_webform_submission_registration_content_node_77_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    ...
    if($form_id == 'webform_submission_registration_content_node_77_form')
    {
        $form['#submit'][] = 'webform_webform_submit_handler';

    }

}

function webform_webform_submit_handler($form, &$form_state) {
    /* This is not displaying any submited values mostly because I haven't clicked on Sumbit button yet */
       dpm($form_state['values']); 
}

src: https://www.drupal.org/node/2634266

Is there any way to get the Form's draft values before submission? Any better approach to process the values within the page(form) itself? Any help much appreciated.

3

1 Answer 1

0

As jrockowitz suggested, the best way to get the webform's data and processing it is, to create custom WebformHandler. Please refer "Creating a custom webform handler plugin for drupal 8" section here for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.