Wicked Wizard dynamic step order

安稳与你 提交于 2019-12-12 22:03:21

问题


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!!!


回答1:


  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


来源:https://stackoverflow.com/questions/25271783/wicked-wizard-dynamic-step-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!