2016-01-06 41 views
3

是否可以在FormWizard表單上添加一個按鈕,以便將用戶導向嚮導中的特定步驟?轉到表單嚮導中的特定步驟

我明顯可以讓他們回去或重新開始,但我希望能夠提供一個機會去特定的步驟,並改變他們的條目。

回答

0

是的,這是可能的。最簡單的方法是,如果你使用簡單的WizardView,你必須發送wizard_goto_step參數等於步驟名稱的值使用NamedUrlWizardView

比方說,你有WizardView與像未來

class OrderWizardView(SessionWizardView): 
    form_list = (
     ('select_customer', forms.WizardCustomerForm), 
     ('products', forms.WizardProductFormset), 
     ('order', forms.WizardOrderForm), 
     ('customer', forms.WizardCustomerDetailsForm), 
     ('review', forms.WizardReviewForm), 
    ) 

步驟上一頁/第一步你可以使用{{ wizard.steps.prev }}{{ wizard.steps.first }}模板變量。

<button name="wizard_goto_step" value="{{ wizard.steps.first }}">First Step</button> 
<button name="wizard_goto_step" value="{{ wizard.steps.prev }}">Prev Step</button> 

如果您需要特定的步驟 - 使用它的名字!

<button name="wizard_goto_step" value="select_customer">Select customer</button> 
<button name="wizard_goto_step" value="products">Add products</button> 
... 
<button name="wizard_goto_step" value="review">Review</button>