craue / CraueFormFlowBundle

Multi-step forms for your Symfony project.
MIT License
736 stars 118 forks source link

Take a step programmatically #341

Open sobocinski opened 5 years ago

sobocinski commented 5 years ago

Hi, Is there any way to insert data and go to the second step automatically? I noticed that the isValid () method immediately save the form data to flow, but only when the request method is POST or PUT. In my case, I have divided the user registration form into two step, but when the user authorizes with Facebook I would like to go automatically to step two (geting data from Facebook works fine for me), and I able to go nextStep(), but without form validation:

$facebookUserRegister = $request->getSession()->get('_fb_login_form');
if($facebookUserRegister instanceof UserRegistration) {    
    $flow->bind($facebookUserRegister);    
    if ($flow->nextStep()) {           
         $flow->saveCurrentStepData($flow->createForm());
    }
}
else {
    $form = $submittedForm = $flow->createForm();
}

this solution does not meet my expectations. Is it possible to set the data manually and validate until the next stop?

PastisD commented 4 years ago

I did that in this commit https://github.com/Vigicorp/CraueFormFlowBundle/commit/f5aea0a8de9d5cce65beeb260f3f9c658e78ce0e

You just have to do this to defnie the default step $flow->setDefaultStepNumber(2);

I don't know if this is the best but i can make a PR.