邪恶精灵动态步序 [英] Wicked Wizard dynamic step order
本文介绍了邪恶精灵动态步序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试根据先前选择的选择更改 wicked Wizard 中的步骤顺序.
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
如果他们选择 :choice_a 等于 2,我只想包括步骤 :optional_page.我尝试了各种配置,但我遇到的真正问题是如果他们回到 :firstpage 并更改步骤并不总是正确的.我相信有人对此有很好的方法,任何帮助将不胜感激!!!
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!!!
推荐答案
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
这篇关于邪恶精灵动态步序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文