{"id":15152729,"url":"https://github.com/sergeypedan/formtastic-grouped-checkboxes","last_synced_at":"2026-02-26T00:50:51.436Z","repository":{"id":179710588,"uuid":"664026162","full_name":"sergeypedan/formtastic-grouped-checkboxes","owner":"sergeypedan","description":"Grouped checkboxes input for Formtastic and ActiveAdmin","archived":false,"fork":false,"pushed_at":"2023-07-09T17:43:29.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-01T21:41:59.065Z","etag":null,"topics":["activeadmin","checkboxes","formtastic","gem","rails","ruby","ruby-gem","ruby-on-rails","rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergeypedan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-08T18:05:31.000Z","updated_at":"2023-07-18T09:36:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"1434ab68-53f0-497c-8e6b-2aaa3e24b1ee","html_url":"https://github.com/sergeypedan/formtastic-grouped-checkboxes","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"345a90bff37a8e805008c96a2c1f967013cb21e3"},"previous_names":["sergeypedan/formtastic-grouped-checkboxes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sergeypedan/formtastic-grouped-checkboxes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeypedan%2Fformtastic-grouped-checkboxes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeypedan%2Fformtastic-grouped-checkboxes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeypedan%2Fformtastic-grouped-checkboxes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeypedan%2Fformtastic-grouped-checkboxes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergeypedan","download_url":"https://codeload.github.com/sergeypedan/formtastic-grouped-checkboxes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeypedan%2Fformtastic-grouped-checkboxes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29846216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"ssl_error","status_checked_at":"2026-02-25T22:37:25.960Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activeadmin","checkboxes","formtastic","gem","rails","ruby","ruby-gem","ruby-on-rails","rubygem"],"created_at":"2024-09-26T16:21:57.779Z","updated_at":"2026-02-26T00:50:51.420Z","avatar_url":"https://github.com/sergeypedan.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Formtastic grouped checkboxes\n\n[![Gem Version](https://badge.fury.io/rb/formtastic_grouped_check_boxes.svg)](https://badge.fury.io/rb/formtastic_grouped_check_boxes)\n\nGroup your Formtastic checkboxes like grouped select via “grouped_collection_select” in Rails.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"formtastic_grouped_check_boxes\"\n```\n\nImport our Sass file “formtastic-grouped-check-boxes.css” in your CSS entrypoint that compiles CSS files:\n\n```sass\n// app/assets/stylesheets/application.sass\n\n// Your regular ActiveAdmin files\n@import ...\n@import ...\n\n// This gem’s files\n@import \"formtastic-grouped-check-boxes\"\n```\n\n## Use\n\nThis gem adds a new input type `:grouped_check_boxes`.\n\nIt also adds 3 new input options, 2 of which follow the Rails naming convention from `grouped_collection_select` ([docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-grouped_collection_select)):\n\n- `group_method` — The name of a method which, when called on a member of `collection`, returns an array of child objects. It can also be a `Proc` / `lambda`, that will be called for each member of the collection to retrieve the value.\n- `group_label_method` — The name of a method which, when called on a member of collection, returns a string to be used as the group name. No `Proc` support here yet.\n- `group_label_parent` — Whether to prepend the fieldset label with the parent input title (on: “Technologies / Marketing”, off: “Marketing”).\n\n### Example\n\nProviding that our models look like so:\n\n```ruby\nclass Project \u003c ApplicationRecord\n  has_many :technologies # details omitted\n  accepts_nested_attributes_for :technologies\nend\n```\n\n```ruby\nclass Technology \u003c ApplicationRecord\n  has_many :projects # details omitted\n  belongs_to :area, foreign_key: :area_id, class_name: \"TechnologyArea\", optional: true\nend\n\n# Table name: technologies\n#  id       :bigint  not null, primary key\n#  name     :string  not null\n#  area_id  :bigint\n```\n\n```ruby\nclass TechnologyArea \u003c ApplicationRecord\n  has_many :technologies\nend\n\n# Table name: technology_areas\n#  id    :bigint  not null, primary key\n#  name  :string  not null\n```\n\nIn ActiveAdmin you can do the following\n\n```ruby\nActiveAdmin.register Project do\n  permit_params technology_ids: [], ...\n\n  form do |f|\n    f.inputs \"Technologies\" do\n      f.input :technologies,\n              as: :grouped_check_boxes, \\\n              collection: Technology.order(:name) \\\n                          .select(:id, :name, :area_id) \\ # note the `:area_id`\n                          .includes(:area), \\ # prevent N+1\n              group_method: :area, \\ # calls `.area` on each instance of `Technology` (that’s why we need `:area_id`)\n              group_label_method: :name, \\ # calls `.name` on each instance of `TechnologyArea`\n              group_label_parent: true # not required\n    end\n  end\nend\n```\n\nResults in:\n\n![screenshot-1](https://github.com/sergeypedan/formtastic-grouped-checkboxes/assets/2311484/7f553b64-d461-4d60-845d-829ba36e3768)\n\nWhile producing such code:\n\n```html\n\u003cfieldset class=\"inputs\"\u003e\n  \u003clegend\u003e\u003cspan\u003eTechnologies\u003c/span\u003e\u003c/legend\u003e\n  \u003col\u003e\n    \u003cli class=\"grouped_check_boxes check_boxes input optional\" id=\"project_technologies_input\"\u003e\n      \u003cinput type=\"hidden\" name=\"project[technology_ids][]\" id=\"project_technologies_none\" value=\"\" autocomplete=\"off\"\u003e\n\n      \u003cfieldset class=\"choices grouped_check_boxes__choices\"\u003e\n        \u003clegend class=\"label grouped_check_boxes__legend\"\u003e\n          \u003clabel class=\"grouped_check_boxes__legend__label\"\u003eTechnologies / No subgroup\u003c/label\u003e\n        \u003c/legend\u003e\n\n        \u003col class=\"choices-group grouped_check_boxes__choices-group\"\u003e\n          \u003cli class=\"choice grouped_check_boxes__choice\"\u003e\n            \u003clabel for=\"project_technology_ids_46\"\u003e\n              \u003cinput type=\"checkbox\" name=\"project[technology_ids][]\" id=\"project_technology_ids_46\" value=\"46\"\u003eBitBucket\n            \u003c/label\u003e\n          \u003c/li\u003e\n          \u003cli class=\"choice grouped_check_boxes__choice\"\u003e\n            \u003clabel for=\"project_technology_ids_138\"\u003e\n              \u003cinput type=\"checkbox\" name=\"project[technology_ids][]\" id=\"project_technology_ids_138\" value=\"138\"\u003eBrainTree API (Ruby SDK)\n            \u003c/label\u003e\n          \u003c/li\u003e\n        \u003c/ol\u003e\n      \u003c/fieldset\u003e\n\n      \u003cfieldset class=\"choices grouped_check_boxes__choices\"\u003e\n        \u003clegend class=\"label grouped_check_boxes__legend\"\u003e\n          \u003clabel class=\"grouped_check_boxes__legend__label\"\u003eTechnologies / Marketing\u003c/label\u003e\n        \u003c/legend\u003e\n\n        \u003col class=\"choices-group grouped_check_boxes__choices-group\"\u003e\n          \u003cli class=\"choice grouped_check_boxes__choice\"\u003e\n            \u003clabel for=\"project_technology_ids_59\"\u003e\n              \u003cinput type=\"checkbox\" name=\"project[technology_ids][]\" id=\"project_technology_ids_59\" value=\"59\"\u003eDirect sales\n            \u003c/label\u003e\n          \u003c/li\u003e\n          \u003cli class=\"choice grouped_check_boxes__choice\"\u003e\n            \u003clabel for=\"project_technology_ids_89\"\u003e\n              \u003cinput type=\"checkbox\" name=\"project[technology_ids][]\" id=\"project_technology_ids_89\" value=\"89\"\u003eGoogle Analytics\n            \u003c/label\u003e\n          \u003c/li\u003e\n        \u003c/ol\u003e\n      \u003c/fieldset\u003e\n    \u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/fieldset\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeypedan%2Fformtastic-grouped-checkboxes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergeypedan%2Fformtastic-grouped-checkboxes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeypedan%2Fformtastic-grouped-checkboxes/lists"}