Skip to content

Commit

Permalink
Add form_for examples to README
Browse files Browse the repository at this point in the history
form_for needs more examples and documentation, but this will do for now.
  • Loading branch information
claudiofullscreen committed Aug 22, 2014
1 parent 0b5614e commit 6b42581
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@ For more information about changelogs, check
[Keep a Changelog](http://keepachangelog.com) and
[Vandamme](http://tech-angels.github.io/vandamme).

## 0.0.5 - 2014-08-22

* [FEATURE] Add `form_for` and form helpers for every type of field

## 0.0.4 - 2014-08-17

* [FEATURE] Add `modal`
Expand Down
37 changes: 14 additions & 23 deletions README.md
Expand Up @@ -46,7 +46,7 @@ How to install

Bh is meant to be included in Rails apps by adding this line to the Gemfile:

gem 'bh', '~> 0.0.4'
gem 'bh', '~> 0.0.5'

Since the gem follows [Semantic Versioning](http://semver.org),
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
Expand Down Expand Up @@ -506,45 +506,36 @@ To apply Bootstrap classes and attributes, you **must** set the `:layout` option
* `:horizontal`, in order to get a [Horizontal form](http://getbootstrap.com/css/#forms-horizontal)
* `:inline`, in order to get an [Inline form](http://getbootstrap.com/css/#forms-inline)

Basic form
-----------
Here is how a form with a text field and a submit button looks like with each layout:

```rhtml
<%= form_for user, layout: :basic do |f| %>
<%= f.fieldset 'Basic Info' do %>
<%= f.text_field :name %>
<%= f.text_field :age %>
<% end %>
<%= form_for @user, layout: :basic do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
```

![form-for-basic](https://cloud.githubusercontent.com/assets/7408595/4015592/30611478-2a2c-11e4-8e62-b60e2151ff12.png)

Horizontal form
---------------

```rhtml
<%= form_for user, layout: :horizontal do |f| %>
<%= f.fields_for :address do |address_f| %>
<%= address_f.text_field :street, label: 'Street/Road' %>
<%= address_f.text_area :notes, cols: 2 %>
<% end %>
<%= f.submit 'Send', class: 'pull-right' %>
<%= form_for @user, layout: :horizontal do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
```

Inline form
-----------
![form-for-horizontal](https://cloud.githubusercontent.com/assets/7408595/4015593/30620ba8-2a2c-11e4-90c9-8340b5ddc113.png)

```rhtml
<%= form_for user, layout: :inline do |f| %>
<%= f.email_field :email %>
<%= f.password_field :password %>
<%= f.check_box :remember_me %>
<%= f.submit 'Login', context: :success %>
<%= form_for @user, layout: :inline do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
```

![form-for-inline](https://cloud.githubusercontent.com/assets/7408595/4015591/30609b74-2a2c-11e4-989e-e509d72ed224.png)


How to release new versions
===========================
Expand Down
2 changes: 1 addition & 1 deletion lib/bh/version.rb
@@ -1,3 +1,3 @@
module Bh
VERSION = '0.0.4'
VERSION = '0.0.5'
end

0 comments on commit 6b42581

Please sign in to comment.