简体   繁体   中英

formtastic ajax autocomplete that outputs cheboxes

My need is to make more usable a simple form which includes one-to-many relationship. Let's say we have Users and Roles. One user has many roles.

Using formtastic somewhere in the User form I'm having user details and then:

f.inputs :roles, :as => :check_boxes, :required => false

This way formtastic will give me the chance to manage user's roles rendering all roles as checkbox.

Now let's pretend we have hundreds of roles... While it would still work, it would become tedious to use. To solve this problem I thought to build an autocomplete field which generates labeled checboxes containing matched roles in the search.

Problem is... I can't understand where to start! Can someone give me some hints please?

Thanks

I would use JavaScript to wrap a dropdown select. Perhaps consider using or modifying this jQuery plugin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM