Rails3 + Typus: display habtm relationship as chec

2019-05-19 06:12发布

问题:

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`