From 41323f6b922f75297075bdb9588eaad15c0e279e Mon Sep 17 00:00:00 2001 From: Harshal LADHE Date: Thu, 25 May 2023 10:24:09 +0530 Subject: [PATCH] Updated README --- README.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20757a1..2bc37a9 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ And follow the remaining instructions in the [official bootstrap installation gu Add the `rails_bootstrap_form` gem to your `Gemfile`: ```ruby -gem "rails_bootstrap_form", "~> 0.6.1" +gem "rails_bootstrap_form", "~> 0.7.2" ``` Then: @@ -66,3 +66,97 @@ The current configuration options are: | Option | Default value | Description | |---------------------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `default_form_attributes` | | Set this option to `{role: "form"}` to make forms non-compliant with W3C, but generate the `role="form"` attribute. | + +## 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: + +![Example 1](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/9a7bbbe9-0ee8-4777-9f2c-2b1425f0184c) + +```erb +<%= bootstrap_form_for(@user) do |f| %> + <%= f.email_field :email %> + <%= f.password_field :password %> + <%= f.check_box :remember_me %> + <%= f.primary "Log In" %> +<% end %> +``` + +This generates the following HTML: + + +```html +
+
+ + +
+
+ + +
+
+ + + +
+ +
+``` + +### bootstrap_form_with + +To get started, use the `bootstrap_form_with` helper in place of the Rails `form_with` helper. Here's an example: + +![Example 2](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/621421b1-4cd3-4dd0-b2dd-89c5893917dc) + +```erb +<%= bootstrap_form_with(model: @user) do |f| %> + <%= f.email_field :email %> + <%= f.password_field :password %> + <%= f.check_box :remember_me %> + <%= f.primary "Log In" %> +<% end %> +``` + +This generates the following HTML: + + +```html +
+
+ + +
+
+ + +
+
+ + + +
+ +
+``` + +## Supported form helpers + +This gem wraps most of the form field helpers. Here's the current list: + +``` +check_box collection_check_boxes collection_radio_buttons +collection_select color_field date_field +date_select datetime_field datetime_local_field +datetime_select email_field file_field +grouped_collection_select hidden_field month_field +number_field password_field phone_field +radio_button range_field rich_text_area +search_field select static_field +telephone_field text_area text_field +time_field time_select time_zone_select +url_field week_field weekday_select +```