{"id":18546661,"url":"https://github.com/proctoru/parliament","last_synced_at":"2025-08-19T08:34:54.555Z","repository":{"id":89622245,"uuid":"119185637","full_name":"ProctorU/parliament","owner":"ProctorU","description":"Nested fields using vanilla JavaScript","archived":false,"fork":false,"pushed_at":"2019-06-07T00:37:53.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-05-15T07:09:03.048Z","etag":null,"topics":[],"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/ProctorU.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-27T17:23:36.000Z","updated_at":"2019-06-07T00:37:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee797310-d255-47c5-b613-00414c5fac6c","html_url":"https://github.com/ProctorU/parliament","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ProctorU/parliament","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProctorU%2Fparliament","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProctorU%2Fparliament/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProctorU%2Fparliament/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProctorU%2Fparliament/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProctorU","download_url":"https://codeload.github.com/ProctorU/parliament/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProctorU%2Fparliament/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271122294,"owners_count":24702974,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-06T20:26:27.189Z","updated_at":"2025-08-19T08:34:54.528Z","avatar_url":"https://github.com/ProctorU.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parliament 🔨\n\nVanilla JavaScript nested form builder. Its name is derived from ProctorU's mascot, which is an owl. A group of owls when assembled is called a parliament, and it was in fact a parliament that created this gem.\n\n## Table of contents\n\n* [Installation](#installation)\n* [Usage](#usage)\n* [Developing](#developing)\n* [License](#license)\n* [Credits](#credits)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'parliament'\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install parliament\n```\n\n**Note**: If you use turbolinks, this should be placed _after_ loading turbolinks.\n\nIn your application.js:\n\n```javascript\n//= require parliament\n```\n## Usage\n\n**Models**\n\n* Add `accepts_nested_attributes_for` to your parent.\n* Add `belongs_to` to your association.\n\n**Controllers**\n\nAdd the parameters to your controllers for strong params\n- `id` and `_destroy` are required for Strong Params.\n\nExample:\n\n  ```ruby\n  # Projects Controller\n  # app/controllers/projects_controller.rb\n\n  private\n\n  def project_params\n    params.require(:project).permit(:name, :description, tasks_attributes: [:id, :description, :done, :_destroy])\n  end\n  ```\n\n**Form**\n\n* Add a `fields_for` loop that you render your fields partial from, passing each object to it.\n* Ensure you call the `f.add_association` helper where you want the link displayed that a user will press to inject another field onto the DOM.\n\nIn the case of a Project/Tasks association:\n\nExample:\n\n  ```erb\n  # Rest of file omitted\n  \u003cdiv class=\"form-group\"\u003e\n    \u003c%= f.label(:tasks) %\u003e\n\n    \u003c%= f.fields_for :tasks do |task| %\u003e\n      \u003c%= render 'task_fields', f: task %\u003e\n    \u003c% end %\u003e\n\n    \u003c%= f.add_association 'Add Task',\n      'tasks',\n      class: 'btn btn-secondary btn-sm' %\u003e\n  \u003c/div\u003e\n\n  # Rest of file omitted\n  ```\n\nInside of your record's fields partial:\n\n* Use the `f.remove_association` helper. This will execute JavaScript to remove the proper element from the page.\n* Ensure the contents of the fields are wrapped in a div with the `nested-fields` CSS class.\n\n**_task_fields.html.erb**\n```erb\n\u003cdiv class=\"nested-fields\"\u003e\n  \u003c%= f.text_field :description, class: \"form-control\" %\u003e\n\n  \u003c%= f.check_box :done %\u003e\n  \u003c%= f.label :done %\u003e\n\n  \u003c%= f.remove_association 'Remove', { class: 'btn btn-outline-danger' } %\u003e\n\u003c/div\u003e\n```\n\n## Developing\n\n1. Thank you! We love [our contributors](https://github.com/ProctorU/parliament/graphs/contributors)!\n1. Clone the repository.\n1. Make your changes in a thoughtfully-named branch.\n1. Ensure 1:1 test coverage.\n1. Submit a [Pull Request](https://github.com/ProctorU/parliament/pulls)!\n1. Celebrate! :tada:\n\n## License\n\nThis project uses MIT-LICENSE.\n\n## Credits\n\nParliament is maintained and funded by [ProctorU](https://twitter.com/ProctorU),\na simple online proctoring service that allows you to take exams or\ncertification tests at home.\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://twitter.com/ProctorUEng\"\u003e\n    \u003cimg src=\"https://s3-us-west-2.amazonaws.com/dev-team-resources/procki-eyes.svg\" width=108 height=72\u003e\n  \u003c/a\u003e\n\n  \u003ch3 align=\"center\"\u003e\n    \u003ca href=\"https://twitter.com/ProctorUEng\"\u003eProctorU Engineering \u0026 Design\u003c/a\u003e\n  \u003c/h3\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproctoru%2Fparliament","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproctoru%2Fparliament","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproctoru%2Fparliament/lists"}