Great tips. Can you can a previous and next step buttons?. If I have form with 8 steps. Let assume I am on the 7th step and decide to change an attribute on step 2. How do I get back to step 2? Thanks
☒ I would handle this with the buttons as the names would have a commit param. I'm not sure how this would be handled in i18n land. I'd assume that you'd pass a value attribute on the form.submit with previous or continue.
You can then navigate to the appropriate routes on the create action.
def create
@company_profile = CompanyProfile.new(company_profile_params)
if @company_profile.valid?
session[:company_profile] = {
name: @company_profile.name,
website: @company_profile.website
}
redirect_to redirection_url
else
render :new
end
end
private
def redirection_url
case params[:commit]
when "Continue"
new_wizards_companies_location_path
when "Previous
new_wizards_companies_[PREVIOUS_RESOURCE_STEP_HERE]_path
else
# handle non matching (likely the next step)
end
end
One quick question - if I wanted to use the form data as search parameters, how would I tweak it at the end of the form to do this?
EDIT: I'm also struggling to render the first step of my form from my root index, since it's not a _partial. I tried creating a partial to render but then the submit/continue to step 2 doesn't work.
Hi ☒ Awesome episode. I am curious if you have any thoughts on this type of implementation vs. using the wicked gem?
Also, I'd be curious to learn how you go about saving state in this type of implementation. Aka. user proceeds through the wizard. At some step they log out, and some time in the future they log back in.
Can you can a previous and next step buttons?. If I have form with 8 steps. Let assume I am on the 7th step and decide to change an attribute on step 2. How do I get back to step 2?
Thanks
You can then navigate to the appropriate routes on the create action.
Thanks, David.
One quick question - if I wanted to use the form data as search parameters, how would I tweak it at the end of the form to do this?
EDIT: I'm also struggling to render the first step of my form from my root index, since it's not a _partial. I tried creating a partial to render but then the submit/continue to step 2 doesn't work.
Also, I'd be curious to learn how you go about saving state in this type of implementation. Aka. user proceeds through the wizard. At some step they log out, and some time in the future they log back in.
Thanks!
I want to upload an image with the multi-step form. How can I go about this?