创建跨越多个模型的向导式表单

发布于 2024-10-15 08:20:07 字数 450 浏览 3 评论 0 原文

正如标题所示,我正在寻找一种解决方案来实现向导式表单,该表单将跨越多个模型。当然,我确实找到了一些资源,但它们都集中在一个模型上。我

  1. acts_as_wizard 插件
  2. Ryan's Railscast 217-multistep-forms" rel="nofollow">多步表单

我的情况还有一个问题是,向导式的创建内容并不是唯一的方法,这就是我认为插件和Railscast 假设。也就是说,我可以使用向导风格按顺序创建对象或以临时方式创建单个对象。

因此,我最好将代码限制为模型或模块,而不是弄乱控制器代码。 提前致谢!

As the title suggests, I'm looking for a solution to implement a wizard-style form, which would span multiple models. Of course I did find a few resources but all of them focussed on a single model. I found

  1. The acts_as_wizard plugin
  2. Ryan's Railscast on multi-step forms

One more catch in my situation is, the wizard-style of creating stuff is not the only way, which is what I think the plugin and the railscast assume. That is, I could use the wizard style of creating objects in a sequence or create individual objects in an adhoc fashion.

So, I would preferably restrict code to models or modules and not mess with controller code.
Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

許願樹丅啲祈禱 2024-10-22 08:20:07

这周我也以同样的方式工作。

我有一个多模型向导,其中每一步都涉及一组模型。我确实使用“交易”(旧的 ActiveModel 交易)进行工作,现在它是一个 gem

所以基本上,我的表单加载总是相同的视图,我只是重新加载它。该视图重新加载特定步骤的部分内容。在我的向导中,所有 (4) 个步骤都是强制性的。因此,如果用户完成前面的步骤,就可以进一步进行操作。我提交,保存我必须的对象,然后进入下一步。如果您打算在最后放一个步骤作为回顾,那么您首先回顾您所做的事情,然后应用它。我建议您制作一个隐藏和取消隐藏步骤的单一表单。您可以使用 javascript 轻松完成。

i'm working in the same pattern this week.

I have a multi model wizard, where every step touch a set of models. I did work using "transactions", the old ActiveModel transations, that now is a gem.

So basically, my form load always the same view, where i just reload it. this view reload a partial for a specific step. In my wizard all (4) steps are mandatory. so the user is just able to go further if he complete the previous steps. I submit, save the objects that i have to and then move to the next step. If you plan to put one step as review in the end, where you first review what you did and then you apply it. i would recommend to do one single form where you hide and unhide the steps. You can do it easily with javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文