Rails3 + Typus:将habtm关系显示为复选框 [英] Rails3 + Typus: display habtm relationship as checkboxes

查看:189
本文介绍了Rails3 + Typus:将habtm关系显示为复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Typus 管理我的管理后端

I'm managing my admin backend with Typus

我要为每个类别添加一个带有复选框的字段。

我使用此代码:

I want to add a field with a checkbox for each category.
I used this code:

Post:
  fields:
    default: name, description, user, categories
    list: name, description, user, categories
    form: name, description, user, categories
  relationships: categories

但结果是一个带有[我解决了这个问题?

是否有本地方法或必须覆盖字段模板?

But the result is a textfield with a [] inside: how do I solve this?
Is there a native way or must I override the field template?

推荐答案

显示您可以使用Typus现有模板的字段复选框

To show the the checkbox for the fields you can use the existing template of the Typus

Post:
  fields:
   default: name, description, user, categories
   list: name, description, user, categories
   form: name, description, user, categories
   options:
     templates:
       categories: boolean
   relationships: categories`

这篇关于Rails3 + Typus:将habtm关系显示为复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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