为每个页面制作一个具有不同结果的多步骤选择过程

时间:2023-01-12 12:47:08

On any given page (It's used site-wide for different purposes) I'd like to call a function getMyForm() or something similar and this would render a several step selection process for a product. We only have this one product but it is quite a complex selection process.

在任何给定页面上(它在不同目的的站点范围内使用)我想调用一个函数getMyForm()或类似的东西,这将为产品提供一个步骤选择过程。我们只有这一个产品,但这是一个非常复杂的选择过程。

If I wanted to implement this on one page only it would be fairly simple... but I'd like this selection process to be available on different pages, and it seems silly for me to recreate the form for each page used when it's only really the outcome after the selection process that will change for each.

如果我想在一个页面上实现这一点,那就相当简单......但是我希望这个选择过程可以在不同的页面上使用,对于我来说,重新创建每个页面的表单似乎很愚蠢确实是选择过程后的结果,每个都会改变。

How would I go about achieving this:

我将如何实现这一目标:

  1. Should I have the form on it's own page anyway then link to it at the beginning of the selection process and redirect to the appropriate page after selection depending on the page the user first came from?

    我是否应该在其自己的页面上拥有该表单,然后在选择过程开始时链接到它并根据用户首次来自的页面重定向到选择后的相应页面?

  2. Use a service container or similar to render the form on the specific page, then use session attributes/variables to track which step the user is currently on, and refresh the current page after each selection.

    使用服务容器或类似工具在特定页面上呈现表单,然后使用会话属性/变量来跟踪用户当前所在的步骤,并在每次选择后刷新当前页面。

  3. Something completely different?

    完全不同的东西?

Additional stuff:

  • I want this to be functional without javascript/jQuery, but this would be a nice addition in future so I don't want to rule it out if possible.

    我希望这个功能没有javascript / jQuery,但是这将是一个很好的补充,所以我不想在可能的情况下排除它。

  • The selection process is dependent on what was selected in the previous step, so I can't just render the whole form in step one, and some kind of refresh will be required.

    选择过程取决于上一步中选择的内容,因此我不能在第一步中呈现整个表单,并且需要进行某种刷新。

1 个解决方案

#1


0  

First, i'd say you can't completely avoid javascript your selection process, if only for triggering change event on your selectors. Having user to manually trigger page refresh through some button doesn't seem like a good idea.

首先,我要说你不能完全避免javascript你的选择过程,如果只是为了触发选择器上的更改事件。让用户通过某个按钮手动触发页面刷新似乎不是一个好主意。

But if you're so inclined, you need to create a form controller with form builder, there just check a request and render a form accordingly.

但是如果您如此倾向,则需要使用表单构建器创建表单控制器,只需检查请求并相应地呈现表单。

For example, if no request is supplied it renders a starting form contains only one select and a submit button, and its action is simple submit to the same page. Main page controller includes a form controller, so form controller gets a request and renders second part and so on...

例如,如果没有提供请求,则呈现一个起始表单只包含一个select和一个提交按钮,其操作很简单,提交到同一页面。主页面控制器包括一个表单控制器,因此表单控制器获取请求并呈现第二部分,依此类推......

#1


0  

First, i'd say you can't completely avoid javascript your selection process, if only for triggering change event on your selectors. Having user to manually trigger page refresh through some button doesn't seem like a good idea.

首先,我要说你不能完全避免javascript你的选择过程,如果只是为了触发选择器上的更改事件。让用户通过某个按钮手动触发页面刷新似乎不是一个好主意。

But if you're so inclined, you need to create a form controller with form builder, there just check a request and render a form accordingly.

但是如果您如此倾向,则需要使用表单构建器创建表单控制器,只需检查请求并相应地呈现表单。

For example, if no request is supplied it renders a starting form contains only one select and a submit button, and its action is simple submit to the same page. Main page controller includes a form controller, so form controller gets a request and renders second part and so on...

例如,如果没有提供请求,则呈现一个起始表单只包含一个select和一个提交按钮,其操作很简单,提交到同一页面。主页面控制器包括一个表单控制器,因此表单控制器获取请求并呈现第二部分,依此类推......