{"id":19474612,"url":"https://github.com/tomasc/simple_form_dependent_fields","last_synced_at":"2026-05-12T12:08:49.870Z","repository":{"id":33143294,"uuid":"149270614","full_name":"tomasc/simple_form_dependent_fields","owner":"tomasc","description":"Show or hide dependent fields in forms based on checkboxes, radios and selects.","archived":false,"fork":false,"pushed_at":"2023-01-19T09:01:03.000Z","size":845,"stargazers_count":0,"open_issues_count":36,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T11:47:29.362Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/tomasc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-18T10:31:46.000Z","updated_at":"2019-11-22T13:58:01.000Z","dependencies_parsed_at":"2023-02-10T21:45:37.186Z","dependency_job_id":null,"html_url":"https://github.com/tomasc/simple_form_dependent_fields","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fsimple_form_dependent_fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fsimple_form_dependent_fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fsimple_form_dependent_fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fsimple_form_dependent_fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasc","download_url":"https://codeload.github.com/tomasc/simple_form_dependent_fields/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240697813,"owners_count":19843275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-10T19:25:52.076Z","updated_at":"2026-05-12T12:08:44.842Z","avatar_url":"https://github.com/tomasc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Form Dependent Fields\n\n[![Build Status](https://travis-ci.org/tomasc/simple_form_dependent_fields.svg)](https://travis-ci.org/tomasc/simple_form_dependent_fields) [![Gem Version](https://badge.fury.io/rb/simple_form_dependent_fields.svg)](http://badge.fury.io/rb/simple_form_dependent_fields) [![Coverage Status](https://img.shields.io/coveralls/tomasc/simple_form_dependent_fields.svg)](https://coveralls.io/r/tomasc/simple_form_dependent_fields)\n\nDependent fields helper for [`simple_form`](https://github.com/plataformatec/simple_form).\n\nShow or hide dependent fields in forms based on checkboxes, radios and selects.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'simple_form_dependent_fields'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install simple_form_dependent_fields\n\nThen require the javascript in your `application.js` (if using Sprockets):\n\n```\n//= require simple_form_dependent_fields\n```\n\nand initialise the plugin like this:\n\n```js\n$(document).ready(\n  function() {\n    $(\".simple_form_dependent_fields\").SimpleFormDependentFields()\n  }\n)\n```\n\n## Usage\n\n```ERB\n\u003c%= simple_form_for @my_doc do |f| %\u003e\n  \u003c%= f.input :doc_type, as: :select, collection: %w[text image video], include_blank: false %\u003e\n\n  \u003c%= f.dependent_fields depends_on_any: { doc_type: 'text' } do %\u003e\n    \u003c%= f.input :text %\u003e\n    \u003c%= f.input :has_title, as: :boolean %\u003e\n  \u003c% end %\u003e\n\n  \u003c%= f.dependent_fields depends_on_all: { doc_type: 'text', has_title: true } do %\u003e\n    \u003c%= f.input :title %\u003e\n  \u003c% end %\u003e\n\n  \u003c%= f.dependent_fields depends_on_none: { doc_type: 'text' } do %\u003e\n    \u003c%= f.input :caption %\u003e\n  \u003c% end %\u003e\n\u003c% end %\u003e\n```\n\nThe `dependent_fields` helper accepts either of the following options:\n\n```RUBY\ndepends_on_any: { field: value, other_field: value }\ndepends_on_all: { field: value, other_field: value }\ndepends_on_none: { field: value, other_field: value }\n```\n\n## Todo\n\n* Multiple select field\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tomasc/simple_form_dependent_fields. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasc%2Fsimple_form_dependent_fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasc%2Fsimple_form_dependent_fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasc%2Fsimple_form_dependent_fields/lists"}