How to set form state complete for previous steps in webform multistep form and direct edit from perticular step and save the data

Created on 24 October 2024, about 2 months ago

Problem/Motivation

I have a multistep form that have 5 steps
welcome, personal_information, validate_otp, accounts_details, webform_complete.
User can fill the form anonoumsly after OTP verification.
Now i have to allow user to edit this form anonymously using secure token, i am using mobile number at time of form submit to get submission id and creating a edit url with secure token and redirecting the user directly on accounts_details page as it should only user can edit.

Steps to reproduce

When i redirect user to accounts_details page webform automatically redirects to first i.e welcome page.
to fix this i have added a code to stay on current page.

function otp_webform_webform_submission_prepare_form(\Drupal\webform\WebformSubmissionInterface $webform_submission, $operation, \Drupal\Core\Form\FormStateInterface $form_state) {
$current_page = \Drupal::request()->query->get('page');
if($current_page == 'accounts_details'){
$pages = $webform_submission->getWebform()->getPages();
if (isset($pages[$current_page])) {
$form_state->set('current_page', $current_page);
}
}

now I am able to stay on current page i.e accounts_details page. But when i chane the info and click on next button it redirecting me to second page i.e personal_information page.
how i can fix this.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

6.3

Component

Code

Created by

🇮🇳India Sunil Chaurasiya

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024