3

I'm trying to alter the order of the steps in wicked wizard based on the selections form a previous selection.

So currently I have all the steps:

class WWTestController < ApplicationController
  include Wicked::Wizard
  steps :first_page,:optional_page,:second_page

   def show
     @event_object = EventObject.find(params[:event_object_id])

     render_wizard
   end

   def update
     @event_object = EventObject.find(params[:event_object_id])
     @event_object.update_attributes(event_object_params)

     render_wizard @event_object
   end

   private

   def event_entry_params
    params.fetch(:event_object, {}).permit(:choice_a)
   end

end

I want to only include the step :optional_page if they have selection :choice_a to equal 2. I've tried various configs but the real issue I run into is if they go back to the :firstpage and change the steps aren't always correct. I'm sure someone has a good approach to this, any help would be greatly appreciated!!!

MechDog
  • 508
  • 7
  • 18

1 Answers1

3
  def show
    @event_object = EventObject.find(params[:event_object_id])

    # Extra logic based on flow steps - when to skip sth.
    case step
    when :optional_page
      skip_step unless @event_object.choice_a == 2
    end

    render_wizard
  end
Eero
  • 4,704
  • 4
  • 37
  • 40