bod*_*ger 5 django django-forms django-formwizard
是否可以在FormWizard表单上添加一个按钮,该按钮可以将用户定向到向导中的特定步骤?
我显然可以让他们返回或重新开始,但是我希望能够提供机会进入特定步骤并更改其条目。
是的,这是可能的。最简单的方法是使用NamedUrlWizardView
如果您使用简单的WizardView,则必须发送wizard_goto_step值等于步骤名称的参数。
假设您有如下WizardView步骤
class OrderWizardView(SessionWizardView):
form_list = (
('select_customer', forms.WizardCustomerForm),
('products', forms.WizardProductFormset),
('order', forms.WizardOrderForm),
('customer', forms.WizardCustomerDetailsForm),
('review', forms.WizardReviewForm),
)
Run Code Online (Sandbox Code Playgroud)
对于上一步/第一步,您可以使用{{ 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>
Run Code Online (Sandbox Code Playgroud)
如果你需要一个特定的步骤 - 使用它的名字!
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1018 次 |
| 最近记录: |