Rails3 + Typus: display habtm relationship as checkboxes

杀马特。学长 韩版系。学妹 提交于 2019-12-22 12:15:06

问题


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?


回答1:


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`


来源:https://stackoverflow.com/questions/4270512/rails3-typus-display-habtm-relationship-as-checkboxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!