{"id":23479559,"url":"https://github.com/brandnewbox/app-form-builder","last_synced_at":"2025-08-27T07:31:33.004Z","repository":{"id":260662453,"uuid":"475624256","full_name":"brandnewbox/app-form-builder","owner":"brandnewbox","description":"Reference implementation of BNB's Rails FormBuilder","archived":false,"fork":false,"pushed_at":"2024-11-14T17:45:38.000Z","size":27,"stargazers_count":36,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-14T18:33:40.584Z","etag":null,"topics":["formbuilder","forms","rails","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brandnewbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-03-29T21:24:29.000Z","updated_at":"2024-11-14T18:21:03.000Z","dependencies_parsed_at":"2024-11-01T17:31:41.576Z","dependency_job_id":"1c7b28b4-b0a5-415f-93e1-e5be16ad6f28","html_url":"https://github.com/brandnewbox/app-form-builder","commit_stats":null,"previous_names":["brandnewbox/app-form-builder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandnewbox%2Fapp-form-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandnewbox%2Fapp-form-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandnewbox%2Fapp-form-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandnewbox%2Fapp-form-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandnewbox","download_url":"https://codeload.github.com/brandnewbox/app-form-builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231145296,"owners_count":18334634,"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":["formbuilder","forms","rails","ruby","ruby-on-rails"],"created_at":"2024-12-24T19:30:29.407Z","updated_at":"2024-12-24T19:30:31.646Z","avatar_url":"https://github.com/brandnewbox.png","language":"Ruby","readme":"# BNB AppFormBuilder\n\nThe canonical implementation of BNB's custom form builder.\n\nIn the past we've often reached for gems like SimpleForm to implement custom form builders. Form builder gems are amazing feats of engineering, but they were adding complexity to our apps and another layer of config to learn and manage. We found this in-app form builder approach to be more approachable for our team.\n\nBy using an in-app form builder we get a few advantages\n- a unified API between all forms at BNB\n- a customization point for each app to specify how that app wants it's forms to look\n- auto finds the correct input to render each field\n- error messages are automatically added to fields\n\n\nWe wrote up a blog post about this form builder here https://brandnewbox.com/notes/2021/03/form-builders-in-ruby/.\n\n\n## Install\n\nThis is a copy and paste library. There's no gem to install, just copy these files into your Rails app and customize from there. We have a template file that you can use to get started.\n\n```bash\nbin/rails app:template LOCATION=https://raw.githubusercontent.com/brandnewbox/app-form-builder/main/template.rb\n```\n---\n\nAlternatively, you can manually add the files to your Rails app and follow the steps below.\n\n- Add the `app_form_builder.rb` file to the `helpers` folder of the Rails app.\n- Add `default_form_builder AppFormBuilder` into your `ApplicationController` class.\n- Change the Rails error proc behavior to use a blank error proc so that it doesn't override the error styling of the form. You have 2 options here:\n  - Option 1: Change the error proc in your `application.rb` file. This one works well with the `default_form_builder` setting from above.\n    ```ruby\n    config.action_view.field_error_proc = Proc.new { |tag, instance| tag }\n    ```\n  - Option 2: Add a custom helper to your `ApplicationHelper`.\n    ```ruby\n    def app_form_with(*, **, \u0026)\n      AppFormBuilder.with_blank_error_proc do\n        form_with(*, builder: AppFormBuilder, **, \u0026)\n      end\n    end\n    ```\n\n## Docs\n\nThe main entrypoint into the `AppFormBuilder` (drawing inspiration from SimpleForm) is the `input` method.\n\n```ruby\n= f.input :method,\n    as: # symbol, optional, will default to the type of the attribute. calls #{as}_input in the form builder\n    label: # string | false, optional, controls the label text or hides the label\n    hint: # string, optional, adds hint text below the input\n    collection: # array, triggers the select_input method\n    text_method: # symbol, optional, the method to pull the text from the collection\n    value_method: # symbol, optional, the method to pull the value from the collection\n    input_html: # hash, optional, additional html options for the input. Most inputs accept this and try to intelligently merge existing options with customizations\n```\n\n### Examples\n\n```ruby\n# Renders a string field if `name` is a string column\n= f.input :name\n```\n\n```ruby\n# Renders a text area with no label\n= f.input :name, as: :text, label: false\n```\n\n```ruby\n# Example of more full featured forms from our code\n= f.input :full_name, label: t(\"full_name\").titleize\n= f.input :preferred_name, label: t(\"preferred_name\").titleize , hint: t(\"preferred_name_hint\")\n\n\n= f.fields_for :profile do |f|\n  = f.input :work_location, label: t(\"location\"),as: :grouped_select, collection: Profile::WORK_LOCATIONS, group_method: :last, include_blank: t(\"select_state\").titleize, input_html: {style: \"color: #808080;\"}\n  = f.input :tag, label: t(\"position\").titleize, input_html: {placeholder: t(\"enter_position\")}, hint: t(\"enter_position_long\")\n  %h4.pb-2=t(\"optional_info\").titleize\n  = f.input :organization, label: t(\"organization\").titleize\n  = f.input :biography, label: t(\"biography\").titleize, input_html: {placeholder: t(\"biography_hint\")}\n  = f.input :language_list, label: t(\"your_lang\").titleize, collection: User::LANGUAGES, input_html: { multiple: true, data:{ controller: \"tag\", placeholder: t(\"select_language\").titleize } }\n```\n\n\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandnewbox%2Fapp-form-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandnewbox%2Fapp-form-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandnewbox%2Fapp-form-builder/lists"}