bootstrap_form-4.2.0/0000755000004100000410000000000013454441234014611 5ustar www-datawww-databootstrap_form-4.2.0/.travis.yml0000644000004100000410000000145413454441233016725 0ustar www-datawww-datalanguage: ruby rvm: - 2.2.9 - 2.3.6 - 2.4.3 - 2.5.0 gemfile: - test/gemfiles/5.0.gemfile - test/gemfiles/5.1.gemfile - test/gemfiles/5.2.gemfile before_install: - gem i rubygems-update -v '<3' && update_rubygems - gem install bundler -v 1.17.3 --no-document script: - bundle exec rake test matrix: include: # Bleeding edge Ruby - rvm: ruby-head gemfile: test/gemfiles/5.2.gemfile # Next version of Rails - rvm: 2.5.0 gemfile: test/gemfiles/6.0.gemfile # Running one job to execute DANGER bot and linting - rvm: 2.5.0 gemfile: test/gemfiles/5.2.gemfile script: - gem install danger - danger - bundle exec rake rubocop allow_failures: - rvm: ruby-head - rvm: 2.5.0 gemfile: test/gemfiles/6.0.gemfile bootstrap_form-4.2.0/README.md0000644000004100000410000006740013454441234016077 0ustar www-datawww-data⚠️ **This documentation is for the master branch, which is not yet stable and targets Bootstrap v4.** If you are using Bootstrap v3, refer to the stable [legacy-2.7](https://github.com/bootstrap-ruby/bootstrap_form/tree/legacy-2.7) branch. This is a new take on the `bootstrap_form` README. Please leave comments at: #520. You can go back to the traditional [README](/OLD-README.md). --- # bootstrap_form [![Build Status](https://travis-ci.org/bootstrap-ruby/bootstrap_form.svg?branch=master)](https://travis-ci.org/bootstrap-ruby/bootstrap_form) [![Gem Version](https://badge.fury.io/rb/bootstrap_form.svg)](https://rubygems.org/gems/bootstrap_form) `bootstrap_form` is a Rails form builder that makes it super easy to integrate Bootstrap v4-style forms into your Rails application. It provides form helpers that augment the Rails form helpers. `bootstrap_forms`'s form helpers generate the form field and its label and all the Bootstrap mark-up required for proper Bootstrap display. `bootstrap_form` also provides: * [Validation error messages](#validation-and-errors) below the field they correspond to, by default. You can also put the error messages after the label, or turn off `bootstrap_form`'s validation error handling and do it yourself. * Automatic [mark-up for the `required` attribute](#required-fields) on required fields. * An easy way to consistently show [help](#help-text) text on fields. * Mark-up for [Bootstrap horizontal forms](#horizontal-forms) (labels to the left of their fields, like a traditional desktop application), if that's what you want. * Many [options](#form-helpers) to modify or augment the generated mark-up. * A way to [escape to the Rails form helpers](#accessing-rails-form-helpers) if you need to do something that `bootstrap_form` can't do. Some other nice things that `bootstrap_form` does for you are: * Reduces the amount of code in your `.erb` files. * Gets you going faster with Bootstrap, because you don't need to learn all the rules of Bootstrap form mark-up to get started. * Reduces errors, because you're doing less typing. * Makes it easier to see the logic of the form, because it's not mixed in with the Bootstrap mark-up. `bootstrap_form` works like the standard Rails form helpers, and this README assumes you know how they work. You start a form with one of [`bootstrap_form_with`](#bootstrap-form-with), [`bootstrap_form_for`](#bootstrap-form-for), or [`bootstrap_form_tag`](#bootstrap-form-tag) in a view file. You get a form builder that calls the [`bootstrap_form` helpers](#form-helpers) instead of the standard Rails helpers. You use that form builder in the view file to render one or more form fields. ## Requirements `bootstrap_form` supports currently supported versions of Rails: * Ruby 2.2.2+ * Rails 5.0+ (Rails 5.1+ for `bootstrap_form_with`) * Bootstrap 4.0.0+ ## Installation Add it to your Gemfile: ```ruby gem "bootstrap_form", ">= 4.2.0" ``` Then: `bundle install` Then require the CSS in your `application.css` file: ```css /* *= require rails_bootstrap_forms */ ``` ## Usage ### bootstrap_form_for To get started, use the `bootstrap_form_for` helper in place of the Rails `form_for` helper. Here's an example: ```erb <%= bootstrap_form_for(@user) do |f| %> <%= f.email_field :email %> <%= f.password_field :password %> <%= f.check_box :remember_me %> <%= f.submit "Log In" %> <% end %> ``` This generates the following HTML: ```html
``` ### bootstrap_form_tag If your form is not backed by a model, use the `bootstrap_form_tag`. Usage of this helper is the same as `bootstrap_form_for`, except no model object is passed in as the first argument. Here's an example: ```erb <%= bootstrap_form_tag url: '/subscribe' do |f| %> <%= f.email_field :email, value: 'name@example.com' %> <%= f.submit %> <% end %> ``` ### bootstrap_form_with (Rails 5.1+) Note that `form_with` in Rails 5.1 does not add IDs to form elements and labels by default, which are both important to Bootstrap markup. This behaviour is corrected in Rails 5.2. To get started, just use the `bootstrap_form_with` helper in place of `form_with`. Here's an example: ```erb <%= bootstrap_form_with(model: @user, local: true) do |f| %> <%= f.email_field :email %> <%= f.password_field :password %> <%= f.check_box :remember_me %> <%= f.submit "Log In" %> <% end %> ``` This generates: ```html
A good password should be at least six characters long
``` `bootstrap_form_with` supports both the `model:` and `url:` use cases in `form_with`. `form_with` has some important differences compared to `form_for` and `form_tag`, and these differences apply to `bootstrap_form_with`. A good summary of the differences can be found at: https://m.patrikonrails.com/rails-5-1s-form-with-vs-old-form-helpers-3a5f72a8c78a, or in the [Rails documentation](api.rubyonrails.org). ## Form Helpers `bootstrap_form` provides its own version of the following Rails form helpers: ``` button email_field search_field check_box file_field select collection_check_boxes grouped_collection_select submit collection_radio_buttons hidden_field (not wrapped, but supported) telephone_field collection_select month_field text_area color_field number_field text_field date_field password_field time_field date_select phone_field time_select datetime_field radio_button time_zone_select datetime_local_field range_field url_field datetime_select rich_text_area (Rails 6+) week_field ``` By default, the helpers generate a `label` tag, and an `input`, `select`, or `textarea` tag, by calling the Rails `label` helper, and then the Rails helper with the same name as the `bootstrap_form` helper. The `bootstrap_form` helpers accept the same options as the standard Rails form helpers, and pass those options through to the Rails helper. They also accept additional options, described in the following section. ## Form Helper Options Many of the helpers accept the same options. The exceptions are: [button](#submit-buttons), [check_box](#checkboxes-and-radios), [collection_check_boxes](#collections), [collection_radio_buttons](#collections), [collection_select](#selects), [date_select](#date-helpers), [datetime_select](#date-helpers), [file_field](#file-fields), [grouped_collection_select](#selects), [hidden_field](#hidden-fields), [radio_button](#checkboxes-and-radios), [rich_text_area](#rich-text-areas-aka-trix-editor), [select](#selects), [submit](#submit-buttons), [time_select](#date-helpers), [time_zone_select](#selects) The options for the form helpers that aren't in the exceptions list are described in the following sub-sections: ### Labels Use the `label` option if you want to specify the field's label text: ```erb <%= f.password_field :password_confirmation, label: "Confirm Password" %> ``` To hide a label, use the `hide_label: true` option. This adds the `sr-only` class, which keeps your labels accessible to those using screen readers. ```erb <%= f.text_area :comment, hide_label: true, placeholder: "Leave a comment..." %> ``` To add custom classes to the field's label: ```erb <%= f.text_field :email, label_class: "custom-class" %> ``` Or you can add the label as input placeholder instead (this automatically hides the label): ```erb <%= f.text_field :email, label_as_placeholder: true %> ``` ### Input Elements / Controls To specify the class of the generated input tag, use the `control_class` option: ```erb <%= f.text_field :email, control_class: "custom-class" %> ``` ### Help Text To add help text, use the `help` option: ```erb <%= f.password_field :password, help: "Must be at least 6 characters long" %> ``` This generates: ``` Must be at least 6 characters long ``` This gem is also aware of help messages in locale translation files (i18n): ```yml en: activerecord: help: user: password: "A good password should be at least six characters long" ``` Help translations containing HTML should follow the convention of appending `_html` to the name: ```yml en: activerecord: help: user: password_html: "A good password should be at least six characters long" ``` If your model name has multiple words (like `SuperUser`), the key on the translation file should be underscored (`super_user`). You can override help translations for a particular field by passing the `help` option or turn them off completely by passing `help: false`. ### Prepending and Appending Inputs You can pass `prepend` and/or `append` options to input fields: ```erb <%= f.text_field :price, prepend: "$", append: ".00" %> ``` You can also prepend and append buttons. Note: The buttons must contain the `btn` class to generate the correct markup. ```erb <%= f.text_field :search, append: link_to("Go", "#", class: "btn btn-secondary") %> ``` To add a class to the input group wrapper, use the `:input_group_class` option. ```erb <%= f.email_field :email, append: f.primary('Subscribe'), input_group_class: 'input-group-lg' %> ``` ### Additional Form Group Attributes Bootstrap mark-up dictates that most input field types have the label and input wrapped in a `div.form-group`. If you want to add an additional CSS class or any other attribute to the form group div, you can use the `wrapper: { class: 'additional-class', data: { foo: 'bar' } }` option. ```erb <%= f.text_field :name, wrapper: { class: 'has-warning', data: { foo: 'bar' } } %> ``` Which produces the following output: ```erb
``` If you only want to set the class on the form group div, you can use the `wrapper_class` option. It's just a short form of `wrapper: { class: 'additional-class' }`. ### Suppressing the Form Group Altogether You may have want to define your own form group div around a field. To do so, add the option `wrapper: false` to the input field. For example: ``` f.form_group :user do f.email_field :email, wrapper: false end ``` Note that Bootstrap relies on the form group div to correctly format most fields, so if you use the `wrapper: false` option, you should provide your own form group div around the input field. You can write your own HTML, or use the `form_group` helper. ## Selects Our select helper accepts the same arguments as the [default Rails helper](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select). Here's an example of how you pass both options and html_options hashes: ```erb <%= f.select :product, [["Apple", 1], ["Grape", 2]], { label: "Choose your favorite fruit:", wrapper: { class: 'has-warning', data: { foo: 'bar' } } }, { class: "selectpicker" } %> ``` ## Checkboxes and Radios Checkboxes and radios should be placed inside of a `form_group` to render properly. The following example ensures that the entire form group will display an error if an associated validations fails: ```erb <%= f.form_group :skill_level, label: { text: "Skill" }, help: "Optional Help Text" do %> <%= f.radio_button :skill_level, 0, label: "Novice", checked: true %> <%= f.radio_button :skill_level, 1, label: "Intermediate" %> <%= f.radio_button :skill_level, 2, label: "Advanced" %> <% end %> <%= f.form_group :terms do %> <%= f.check_box :terms, label: "I agree to the Terms of Service" %> <% end %> ``` You can also create a checkbox using a block: ```erb <%= f.form_group :terms, label: { text: "Optional Label" } do %> <%= f.check_box :terms do %> You need to check this box to accept our terms of service and privacy policy <% end %> <% end %> ``` To display checkboxes and radios inline, pass the `inline: true` option: ```erb <%= f.form_group :skill_level, label: { text: "Skill" } do %> <%= f.radio_button :skill_level, 0, label: "Novice", inline: true %> <%= f.radio_button :skill_level, 1, label: "Intermediate", inline: true %> <%= f.radio_button :skill_level, 2, label: "Advanced", inline: true %> <% end %> ``` Check boxes and radio buttons are wrapped in a `div.form-check`. You can add classes to this `div` with the `:wrapper_class` option: ```erb <%= f.radio_button :skill_level, 0, label: "Novice", inline: true, wrapper_class: "w-auto" %> ``` ### Switches To render checkboxes as switches with Bootstrap 4.2+, use `custom: :switch`: ```erb <%= f.check_box :remember_me, custom: :switch %> ``` ### Collections `bootstrap_form` also provides helpers that automatically create the `form_group` and the `radio_button`s or `check_box`es for you: ```erb <%= f.collection_radio_buttons :skill_level, Skill.all, :id, :name %> <%= f.collection_check_boxes :skills, Skill.all, :id, :name %> ``` NOTE: These helpers do not currently support a block, unlike their equivalent Rails helpers. See issue #477. Collection methods accept these options: * `:label`: Customize the `form_group`'s label * `:hide_label`: Pass true to hide the `form_group`'s label * `:help`: Add a help span to the `form_group` * Other options will be forwarded to the `radio_button`/`check_box` method ## Static Controls You can create a static control like this: ```erb <%= f.static_control :email %> ``` Here's the output for a horizontal layout: ```html
``` You can also create a static control that isn't based on a model attribute: ```erb <%= f.static_control label: "Custom Static Control" value: "Content Here" %> ``` Prior to version 4 of `bootstrap_form`, you could pass a block to the `static_control` method. The value of the block would be used for the content of the static "control". Bootstrap 4 actually creates and styles a disabled input field for static controls, so the value of the control has to be specified by the `value:` option. Passing a block to `static_control` no longer has any effect. ## Date Helpers The multiple selects that the date and time helpers (`date_select`, `time_select`, `datetime_select`) generate are wrapped inside a `div.rails-bootstrap-forms-[date|time|datetime]-select` tag. This is because Bootstrap automatically styles our controls as `block`s. This wrapper fixes this defining these selects as `inline-block` and a width of `auto`. ## Submit Buttons The `btn btn-secondary` CSS classes are automatically added to your submit buttons. ```erb <%= f.submit %> ``` You can also use the `primary` helper, which adds `btn btn-primary` to your submit button: ```erb <%= f.primary "Optional Label" %> ``` You can specify your own classes like this: ```erb <%= f.submit "Log In", class: "btn btn-success" %> ``` If the `primary` helper receives a `render_as_button: true` option or a block, it will be rendered as an HTML button, instead of an input tag. This allows you to specify HTML content and styling for your buttons (such as adding illustrative icons to them). For example, the following statements ```erb <%= f.primary "Save changes ".html_safe, render_as_button: true %> <%= f.primary do concat 'Save changes ' concat content_tag(:span, nil, class: 'fa fa-save') end %> ``` are equivalent, and each of them both be rendered as: ```html ``` If you wish to add additional CSS classes to your button, while keeping the default ones, you can use the `extra_class` option. This is particularly useful for adding extra details to buttons (without forcing you to repeat the Bootstrap classes), or for element targeting via CSS classes. Be aware, however, that using the `class` option will discard any extra classes you add. As an example, the following button declarations ```erb <%= f.primary "My Nice Button", extra_class: 'my-button' %> <%= f.primary "My Button", class: 'my-button' %> ``` will be rendered as ```html ``` (some unimportant HTML attributes have been removed for simplicity) ## Rich Text Areas AKA Trix Editor If you're using Rails 6, `bootstrap_form` supports the `rich_text_area` helper. ``` <%= f.rich_text_area(:life_story) %> ``` will be rendered as: ```
``` ## File Fields The `file_field` helper generates mark-up for a Bootstrap 4 custom file field entry. It takes the [options for `text_field`](#form-helper-options), minus `append` and `prepend`. ## Hidden Fields The `hidden_field` helper in `bootstrap_form` calls the Rails helper directly, and does no additional mark-up. ## Accessing Rails Form Helpers If you want to use the original Rails form helpers for a particular field, append `_without_bootstrap` to the helper: ```erb <%= f.text_field_without_bootstrap :email %> ``` ## Form Styles By default, your forms will stack labels on top of controls and your controls will grow to 100 percent of the available width. This is consistent with Bootstrap's "mobile first" approach. ### Inline Forms To use an inline-layout form, use the `layout: :inline` option. To hide labels, use the `hide_label: true` option, which keeps your labels accessible to those using screen readers. ```erb <%= bootstrap_form_for(@user, layout: :inline) do |f| %> <%= f.email_field :email, hide_label: true %> <%= f.password_field :password, hide_label: true %> <%= f.check_box :remember_me %> <%= f.submit %> <% end %> ``` To skip label rendering at all, use `skip_label: true` option. ```erb <%= f.password_field :password, skip_label: true %> ``` ### Horizontal Forms To use a horizontal-layout form with labels to the left of the control, use the `layout: :horizontal` option. You should specify both `label_col` and `control_col` css classes as well (they default to `col-sm-2` and `col-sm-10`). In the example below, the checkbox and submit button have been wrapped in a `form_group` to keep them properly aligned. ```erb <%= bootstrap_form_for(@user, layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10") do |f| %> <%= f.email_field :email %> <%= f.password_field :password %> <%= f.form_group do %> <%= f.check_box :remember_me %> <% end %> <%= f.form_group do %> <%= f.submit %> <% end %> <% end %> ``` The `label_col` and `control_col` css classes can also be changed per control: ```erb <%= bootstrap_form_for(@user, layout: :horizontal) do |f| %> <%= f.email_field :email %> <%= f.text_field :age, control_col: "col-sm-3" %> <%= f.form_group do %> <%= f.submit %> <% end %> <% end %> ``` or default value can be changed in initializer: ```erb # config/initializers/bootstrap_form.rb module BootstrapForm class FormBuilder def default_label_col 'col-sm-4' end def default_control_col 'col-sm-8' end end end ``` Control col wrapper class can be modified with `add_control_col_class`. This option will preserve column definition: ```erb <%= bootstrap_form_for(@user, layout: :horizontal) do |f| %> <%= f.email_field :email %> <%= f.text_field :age, add_control_col_class: "additional-control-col-class" %> <%= f.form_group do %> <%= f.submit %> <% end %> <% end %> ``` ### Custom Field Layout The form-level `layout` can be overridden per field, unless the form-level layout was `inline`: ```erb <%= bootstrap_form_for(@user, layout: :horizontal) do |f| %> <%= f.email_field :email %> <%= f.text_field :feet, layout: :default %> <%= f.text_field :inches, layout: :default %> <%= f.form_group do %> <%= f.submit %> <% end %> <% end %> ``` A form-level `layout: :inline` can't be overridden because of the way Bootstrap 4 implements in-line layouts. One possible work-around is to leave the form-level layout as default, and specify the individual fields as `layout: :inline`, except for the fields(s) that should be other than in-line. ### Custom Form Element Styles The `custom` option can be used to replace the browser default styles for check boxes and radio buttons with dedicated Bootstrap styled form elements. Here's an example: ```erb <%= bootstrap_form_for(@user) do |f| %> <%= f.email_field :email %> <%= f.password_field :password %> <%= f.check_box :remember_me, custom: true %> <%= f.submit "Log In" %> <% end %> ``` ## Validation and Errors Rails normally wraps fields with validation errors in a `div.field_with_errors`, but this behaviour isn't consistent with Bootstrap 4 styling. By default, `bootstrap_form` generations in-line errors which appear below the field. But it can also generate errors on the label, or not display any errors, leaving it up to you. ### Inline Errors By default, fields that have validation errors will be outlined in red and the error will be displayed below the field. Here's an example: ```html
can't be blank
``` You can turn off inline errors for the entire form like this: ```erb <%= bootstrap_form_for(@user, inline_errors: false) do |f| %> ... <% end %> ``` ### Label Errors You can also display validation errors in the field's label; just turn on the `:label_errors` option. Here's an example: ``` <%= bootstrap_form_for(@user, label_errors: true) do |f| %> ... <% end %> ``` By default, turning on `:label_errors` will also turn off `:inline_errors`. If you want both turned on, you can do that too: ``` <%= bootstrap_form_for(@user, label_errors: true, inline_errors: true) do |f| %> ... <% end %> ``` ### Alert Messages To display an error message with an error summary, you can use the `alert_message` helper. This won't output anything unless a model validation has failed. ```erb <%= f.alert_message "Please fix the errors below." %> ``` Which outputs: ```html

Please fix the errors below.

``` You can turn off the error summary like this: ```erb <%= f.alert_message "Please fix the errors below.", error_summary: false %> ``` To output a simple unordered list of errors, use the `error_summary` helper. ```erb <%= f.error_summary %> ``` Which outputs: ```html ``` ### Errors On If you want to display a custom inline error for a specific attribute not represented by a form field, use the `errors_on` helper. ```erb <%= f.errors_on :tasks %> ``` Which outputs: ```html
Tasks can't be blank.
``` You can hide the attribute name like this: ```erb <%= f.errors_on :tasks, hide_attribute_name: true %> ``` Which outputs: ```html
can't be blank.
``` ## Required Fields A label that is associated with a required field is automatically annotated with a `required` CSS class. `bootstrap_form` doesn't provide any styling for required fields. You're free to add any appropriate CSS to style required fields as desired. One example would be to automatically add an asterisk to the end of the label: ```css label.required:after { content:" *"; } ``` The label `required` class is determined based on the definition of a presence validator with the associated model attribute. Presently this is one of: ActiveRecord::Validations::PresenceValidator or ActiveModel::Validations::PresenceValidator. In cases where this behaviour is undesirable, use the `required` option to force the class to be present or absent: ```erb <%= f.password_field :login, label: "New Username", required: true %> <%= f.password_field :password, label: "New Password", required: false %> ``` ## Internationalization bootstrap_form follows standard rails conventions so it's i18n-ready. See more here: http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models ## Future Compatibility The Rails team has [suggested](https://github.com/rails/rails/issues/25197) that `form_for` and `form_tag` may be deprecated and then removed in future versions of Rails. `bootstrap_form` will continue to support `bootstrap_form_for` and `bootstrap_form_tag` as long as Rails supports `form_for` and `form_tag`. ## Other Tips and Edge Cases By their very nature, forms are extremely diverse. It would be extremely difficult to provide a gem that could handle every need. Here are some tips for handling edge cases. ### Empty But Visible Labels Some third party plug-ins require an empty but visible label on an input control. The `hide_label` option generates a label that won't appear on the screen, but it's considered invisible and therefore doesn't work with such a plug-in. An empty label (e.g. `""`) causes the underlying Rails helper to generate a label based on the field's attribute's name. The solution is to use a zero-width character for the label, or some other "empty" HTML. For example: ``` label: "​".html_safe ``` or ``` label: "".html_safe ``` ## Code Triage page http://www.codetriage.com/potenza/bootstrap_form ## Contributing We welcome contributions. If you're considering contributing to bootstrap_form, please review the [Contributing](/CONTRIBUTING.md) document first. ## License MIT License. Copyright 2012-2019 Stephen Potenza (https://github.com/potenza) bootstrap_form-4.2.0/RELEASING.md0000644000004100000410000000361113454441234016445 0ustar www-datawww-data# Releasing Follow these steps to release a new version of bootstrap_form to rubygems.org. ## Prerequisites * You must have commit rights to the bootstrap_form repository. * You must have push rights for the bootstrap_form gem on rubygems.org. * You must be using Ruby >= 2.2. * Your GitHub credentials must be available to Chandler via `~/.netrc` or an environment variable, [as explained here](https://github.com/mattbrictson/chandler#2-configure-credentials). ## How to release 1. Run `bundle install` to make sure that you have all the gems necessary for testing and releasing. 2. **Ensure the tests are passing by running `bundle exec rake`.** 3. Determine which would be the correct next version number according to [semver](http://semver.org/). 4. Update the version in `./lib/bootstrap_form/version.rb`. 5. Update the `CHANGELOG.md` (for an illustration of these steps, refer to the [4.0.0.alpha1 commit](https://github.com/bootstrap-ruby/bootstrap_form/commit/8aac3667931a16537ab68038ec4cebce186bd596#diff-4ac32a78649ca5bdd8e0ba38b7006a1e) as an example): * Rename the Pending Release section to `[version][] (date)` with appropriate values `version` and `date` * Remove the "Your contribution here!" bullets from the release notes * Add a new Pending Release section at the top of the file with a template for contributors to fill in, including "Your contribution here!" bullets * Add the appropriate GitHub diff links to the footer of the document 6. Update the installation instructions in `README.md` to use the new version. 7. Commit the CHANGELOG and version changes in a single commit; the message should be "Preparing vX.Y.Z" where `X.Y.Z` is the version being released. 8. Run `bundle exec rake release`; this will tag, push to GitHub, publish to rubygems.org, and upload the latest CHANGELOG entry to the [GitHub releases page](https://github.com/bootstrap-ruby/bootstrap_form/releases). bootstrap_form-4.2.0/CHANGELOG.md0000644000004100000410000003565313454441233016435 0ustar www-datawww-data## [Pending Release][] ### Breaking changes * Your contribution here! ### New features * Your contribution here! ### Bugfixes * Your contribution here! ## [4.2.0][] (2019-03-08) ### New features * [#508] Support `rich_text_area` AKA the Trix editor on Rails 6+. * [#518] Move all inputs to separate, more maintainable files. * [#514](https://github.com/bootstrap-ruby/bootstrap_form/pull/514): Add support for BS 4.2 switches - [@simmerz](https://github.com/simmerz) ### Bugfixes * [#522](https://github.com/bootstrap-ruby/bootstrap_form/pull/522): Clean up rubocop offences - [@simmerz](https://github.com/simmerz) * [#524](https://github.com/bootstrap-ruby/bootstrap_form/pull/524): Fix non-inline layout rendering without help text - [@simmerz](https://github.com/simmerz) ## [4.1.0][] (2019-01-19) ### New features - [#259] Allow to render input without wrapper [@yevhene]. ### Bugfixes * [#496] Ensure required attribute is passed through to input tag. ## [4.0.0][] (2018-10-27) 🚨 **This release adds support for Bootstrap v4 and drops support for Bootstrap v3.** 🚨 If your app uses Bootstrap v3, you should continue using bootstrap_form 2.7.x instead. Bootstrap v3 and v4 are very different, and thus bootstrap_form now produces different markup in order to target v4. The changes are too many to list here; you can refer to Bootstrap's [Migrating to v4](https://getbootstrap.com/docs/4.0/migration/) page for a detailed explanation. In addition to these necessary markup changes, the bootstrap_form API itself has the following important changes in this release. ### Breaking changes * See [Migrating to v4](https://getbootstrap.com/docs/4.0/migration/). ### New features * [#476] Give a way to pass classes to the `div.form-check` wrapper for check boxes and radio buttons - [@lcreid](https://github.com/lcreid). * [461](https://github.com/bootstrap-ruby/bootstrap_form/pull/461): default form-inline class applied to parent content div on date select helpers. Can override with a :skip_inline option on the field helper - [@lancecarlson](https://github.com/lancecarlson). * The `button`, `submit`, and `primary` helpers can now receive an additional option, `extra_class`. This option allows us to specify additional CSS classes to be added to the corresponding button/input, _while_ maintaining the original default ones. E.g., a primary button with an `extra_class` 'test-button' will have its final CSS classes declaration as 'btn btn-primary test-button'. * [#488](https://github.com/bootstrap-ruby/bootstrap_form/pull/488): add required option on form_group_builder - [@ThomasSevestre](https://github.com/ThomasSevestre). ### Bugfixes * [#347](https://github.com/bootstrap-ruby/bootstrap_form/issues/347) Fix `wrapper_class` and `wrapper` options for helpers that have `html_options`. * [#472](https://github.com/bootstrap-ruby/bootstrap_form/pull/472) Use `id` option value as `for` attribute of label for custom checkboxes and radio buttons. * [#478](https://github.com/bootstrap-ruby/bootstrap_form/issues/478) Fix offset for form group without label when multiple label widths are specified. ## [4.0.0.alpha1][] (2018-06-16) 🚨 **This release adds support for Bootstrap v4 and drops support for Bootstrap v3.** 🚨 If your app uses Bootstrap v3, you should continue using bootstrap_form 2.7.x instead. Bootstrap v3 and v4 are very different, and thus bootstrap_form now produces different markup in order to target v4. The changes are too many to list here; you can refer to Bootstrap's [Migrating to v4](https://getbootstrap.com/docs/4.0/migration/) page for a detailed explanation. In addition to these necessary markup changes, the bootstrap_form API itself has the following important changes in this release. ### Breaking changes * Rails 4.x is no longer supported * Ruby 2.2 or newer is required * Built-in support for the `nested_form` gem has been completely removed * The `icon` option is no longer supported (Bootstrap v4 does not include icons) * The deprecated Rails methods `check_boxes_collection` and `radio_buttons_collection` have been removed * `hide_label: true` and `skip_label: true` on individual check boxes and radio buttons apply Bootstrap 4 markup. This means the appearance of a page may change if you're upgrading from the Bootstrap 3 version of `bootstrap_form`, and you used `check_box` or `radio_button` with either of those options * `static_control` will no longer properly show error messages. This is the result of bootstrap changes. * `static_control` will also no longer accept a block, use the `value` option instead. * `form_group` with a block that produces arbitrary text needs to be modified to produce validation error messages (see the UPGRADE-4.0 document). [@lcreid](https://github.com/lcreid). * `form_group` with a block that contains more than one `check_box` or `radio_button` needs to be modified to produce validation error messages (see the UPGRADE-4.0 document). [@lcreid](https://github.com/lcreid). * [#456](https://github.com/bootstrap-ruby/bootstrap_form/pull/456): Fix label `for` attribute when passing non-english characters using `collection_check_boxes` - [@ug0](https://github.com/ug0). * [#449](https://github.com/bootstrap-ruby/bootstrap_form/pull/449): Bootstrap 4 no longer mixes in `.row` in `.form-group`. `bootstrap_form` adds `.row` to `div.form-group` when layout is horizontal. ### New features * Support for Rails 5.1 `form_with` - [@lcreid](https://github.com/lcreid). * Support Bootstrap v4's [Custom Checkboxes and Radios](https://getbootstrap.com/docs/4.0/components/forms/#checkboxes-and-radios-1) with a new `custom: true` option * Allow HTML in help translations by using the `_html` suffix on the key - [@unikitty37](https://github.com/unikitty37) * [#408](https://github.com/bootstrap-ruby/bootstrap_form/pull/408): Add option[:id] on static control #245 - [@duleorlovic](https://github.com/duleorlovic). * [#455](https://github.com/bootstrap-ruby/bootstrap_form/pull/455): Support for i18n `:html` subkeys in help text - [@jsaraiva](https://github.com/jsaraiva). * Adds support for `label_as_placeholder` option, which will set the label text as an input fields placeholder (and hiding the label for sr_only). * [#449](https://github.com/bootstrap-ruby/bootstrap_form/pull/449): Passing `.form-row` overrides default `.form-group.row` in horizontal layouts. * Added an option to the `submit` (and `primary`, by transitivity) form tag helper, `render_as_button`, which when truthy makes the submit button render as a button instead of an input. This allows you to easily provide further styling to your form submission buttons, without requiring you to reinvent the wheel and use the `button` helper (and having to manually insert the typical Bootstrap classes). - [@jsaraiva](https://github.com/jsaraiva). * Add `:error_message` option to `check_box` and `radio_button`, so they can output validation error messages if needed. [@lcreid](https://github.com/lcreid). * [#487](https://github.com/bootstrap-ruby/bootstrap_form/pull/487): Add add_control_col_class option on form_group. - [@ThomasSevestre](https://github.com/ThomasSevestre). * Your contribution here! ### Bugfixes * [#357](https://github.com/bootstrap-ruby/bootstrap_form/pull/357) if provided, use html option `id` to specify `for` attribute on label [@duleorlovic](https://github.com/duleorlovic) ## [2.7.0][] (2017-04-21) Features: * [#325](https://github.com/bootstrap-ruby/bootstrap_form/pull/325): Support :prepend and :append for the `select` helper - [@donv](https://github.com/donv). ## [2.6.0][] (2017-02-03) Bugfixes: - Fix ambiguous first argument warning (#311, @mikenicklas) Features: - Add a FormBuilder#custom_control helper [#289](https://github.com/bootstrap-ruby/bootstrap_form/pull/289) ## [2.5.3][] (2016-12-23) There are no user-facing changes with this release. Behind the scenes, the tests have been greatly improved. The project is now tested against and compatible with the following Rails versions 4.0, 4.1, 4.2 and 5.0 (#278). ## [2.5.2][] (2016-10-08) Bugfixes: - Allow objects without `model_name`s to act as form objects (#295, @laserlemon) - Fix offset for submit for horizontal forms when using non-sm column breakers for label column (#293, @oteyatosys) ## [2.5.1][] (2016-09-23) Bugfixes: - Fix getting help text for elements when using anonymous models (see [issue 282](https://github.com/bootstrap-ruby/bootstrap_form/issues/282)) ## [2.5.0][] (2016-08-12) Bugfixes: - Sanitize