Steps to reproduce the error:
1. Go to form_example/wizard.
2. Fill "First Name" and "Last Name" then click on Next.
4. Fill City and click on Next.
5. Click on Previous you will be on section "Extensible Wizard: Step 2".
6. Click on Previous you will be on section "Extensible Wizard: Step 1".
7. Click on Next you will be on section "Extensible Wizard: Step 2", wait a moment, the text in City field is missing.

Here the patch for fix that.

CommentFileSizeAuthor
#6 lose_data-2598472-6.patch2.08 KBsdstyles
lose_data.patch628 bytesrpayanm

Comments

rpayanm created an issue. See original summary.

rpayanm’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, lose_data.patch, failed testing.

Status: Needs work » Needs review

rpayanm queued lose_data.patch for re-testing.

mile23’s picture

Status: Needs review » Needs work
Issue tags: +Novice, +Needs tests

Nice catch!

+++ b/form_example/form_example_wizard.inc
@@ -155,7 +155,6 @@ function form_example_wizard($form, &$form_state) {
-  $form_state['step_information'][$current_step]['stored_values'] = $form_state['values'];

form_example_wizard_next_submit() does this same thing, with the same result. Add a number for the SSN field, click 'previous' and then click 'next' and the value goes away.

So we need to remove this line from form_example_wizard_next_submit() as well. I'm not entirely sure why it's there to begin with.

I think we should demonstrate how to test this kind of interaction as well. Add some steps to FormExampleTestCase::testWizard() where we click on 'Previous' and verify that the information is still present.

Marking this as Novice and Needs tests so it might find a wider audience. Assign yourself, @rpayanm, if you want to work on it.

Thanks!

sdstyles’s picture

Status: Needs work » Needs review
StatusFileSize
new2.08 KB
+++ b/form_example/form_example_wizard.inc
@@ -155,7 +155,6 @@ function form_example_wizard($form, &$form_state) {
-  $form_state['step_information'][$current_step]['stored_values'] = $form_state['values'];

Removing this code from form_example_wizard_next_submit() will brake the multi-step functionality. I found that form lose city and aunt ssn number values because Previous submit callback has attribute #limit_validation_errors this attribute skip validation and discard form values.
This patch replace $form_state['values'] with $form_state['input'] in form_example_wizard_previous_submit() this allow not to lose values in previous submit callback, also added test coverage for described steps from issue.

navneet0693’s picture

Hi @rpayanm
This patch by @sdstyles works fine for me.

Test Results : Pass On "Extensible Wizard: Step 2" City value is held, after we went to "Extensible Wizard: Step 1" by hitting "Previous".

Drupal 7 Version : 7.43
MySQL : 5.5.42
PHP : 5.6.10

navneet0693’s picture

Status: Needs review » Reviewed & tested by the community

  • Mile23 committed ce52c2f on 7.x-1.x authored by sdstyles
    Issue #2598472 by rpayanm, sdstyles: Data lose when go back
    
mile23’s picture

Status: Reviewed & tested by the community » Fixed

Nice. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.