多级嵌套表单未显示在Active Admin中 [英] Multilevel Nested form not showing in Active Admin

查看:63
本文介绍了多级嵌套表单未显示在Active Admin中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现多层嵌套表单.

I'm trying to Implement a multilevel Nested form.

这些是我的模特

workout.rb

workout.rb

has_many :workout_weeks
accepts_nested_attributes_for :workout_weeks

workout_week.rb

workout_week.rb

belongs_to :workout
has_many :workout_days
accepts_nested_attributes_for :workout_days

workout_day.rb

workout_day.rb

belongs_to :workout_week

我在活跃管理员中的锻炼编辑部分就像

and my workout edit part in active admin is like

form do |f|
  inputs 'Workout Details' do
    f.input :workout_name
    f.inputs do
      f.has_many :workout_weeks, heading: 'Workout Week', allow_destroy: true do |ww|
        ww.input :week_workout_name
        ww.inputs do
          ww.has_many :workout_days, heading: 'Workout Days', allow_destroy: true do |wd|
            wd.input :day_workout_name
          end
        end
      end
    end
    f.actions
  end
end

我在这里没有想念任何东西吗, 在视图中不存在用于编辑的表单字段.它没有生成. 我的看法现在是这样.

Did I miss anything here, The form for edit field is not available in the view. Its not generated. My view is like this now.

为什么我的training_day表单未在此处呈现?

Why is my workout_day form not getting rendered here ?

推荐答案

这应该有效:

form do |f|
  inputs 'Workout Details' do
    f.input :workout_name
    f.inputs do
      f.has_many :workout_weeks, heading: 'Workout Week', allow_destroy: true do |ww|
        ww.input :week_workout_name
        ww.has_many :workout_days, heading: 'Workout Days', allow_destroy: true do |wd|
          wd.input :day_workout_name
        end
      end
    end
    f.actions
  end
end

您不能在inputs

这篇关于多级嵌套表单未显示在Active Admin中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆