weixin_33725272 2009-07-29 19:20 采纳率: 0%
浏览 41

多级复杂Rails表单

I'm trying to create a multi-level ajax form on my rails app that can add/remove fields associated with a new object in a form when a button is clicked. However, I need to have multiple levels to this form (i.e. if someone adds a "Meal" object, there must also be a button inside the created "Meal" form for "Add a food".)

I followed this tutorial (parts 1-3) by Ryan Bates (http://railscasts.com/episodes/73-complex-forms-part-1), but it only describes a single level form. The prototype helper commands for rails do not allow me to put javascript inside javascript however (there is an issue with escaping the characters properly). How else can I create a form like this? Thanks.

  • 写回答

1条回答 默认 最新

  • George_Fal 2009-07-31 23:19
    关注

    The technique in the episodes does not support deep nesting. However, Rails 2.3 introduced a new way to handle multi-model forms called accepts_nested_attributes_for which does support deep nesting. Unfortunately the full solution is too involved to cover here, but I do plan to cover it in future Railscasts episodes.

    In the meantime, I recommend checking out Eloy Duran's example application which shows how to handle deep nesting in Rails 2.3.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?