【问题标题】:Rails nested category list (parent > child) using association使用关联的 Rails 嵌套类别列表(父>子)
【发布时间】:2020-12-07 17:15:42
【问题描述】:

我有 3 个级别的类别。目前,作为 check_box 的关联为我提供了 1 级列表,因此无法判断我是否从 1 级中选择了 3 级项目。

  • 1 级
    • 2 级
      • 3 级

有没有办法在 Parent > Child type of grouped indentation 中列出我的类别?

<%= f.association :categories, :include_blank => false, as: :check_boxes, label: false %>

【问题讨论】:

    标签: ruby-on-rails forms checkbox nested associations


    【解决方案1】:

    尝试根据它们所在的级别为复选框添加一个类,并根据应用的类放置类别。

    category-level-0 {
      font-weight: bold !important;
    }
    category-level-1 {
        padding-left: 20px !important;
    }
    category-level-2 {
        padding-left: 40px !important;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多