foundation_form_builder 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0477eb9127716358d4bb9fe34dca77dc996d838
4
- data.tar.gz: e31b456af9bc42d175f74c5e79144903ceb13f45
3
+ metadata.gz: ece24c8e1a79705694ac2d5695e29a54640772e7
4
+ data.tar.gz: a3faad3150a6b81023e7c96b9b4fc1ab4ebccc70
5
5
  SHA512:
6
- metadata.gz: b8521e19fa073984d097a3a11d85e8cd56dc6814adce66c9a8a60d77e9475cb0bb18718e9e0d4f6306727421dae7155633d181d99b5d5d57c63cd9fb93ee944b
7
- data.tar.gz: 543aa62b08148003fa49e45f3c94c1fbae57f954ae4a4856ebcacbe4a7498ee096d596866626e2fea129b965b2c5b6cf303003fd1ce2fde89cdf8b615448b52d
6
+ metadata.gz: 6f01f5f4bf5e68adfc81b52741c4ccea267c062f1ba2f6993b90bc5b6f7b15da2fd0c2d6b2373b36b38e4db0f718ffd28eca50d44c476bd51dfd2021720da85d
7
+ data.tar.gz: 39110cabc23398f732511fce73733985b7304503309a8c5d5c894fe6c5c241d02e1409d7100072a0de0640ddeefad5bd76d4d679f61b9777e7ea4d7484b52dbe
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # FoundationFormBuilder changelog
2
2
 
3
+ # 0.3.0
4
+
5
+ 27 Feb 2015
6
+
7
+ Explicitly depend on Ruby 2 (since we were already using Ruby 2 syntax). [#1]
8
+
3
9
  # 0.2.1
4
10
 
5
11
  26 Feb 2015
data/README.md CHANGED
@@ -8,15 +8,15 @@
8
8
 
9
9
  [Foundation](http://foundation.zurb.com) is an excellent CSS framework, and provides some [lovely components](http://foundation.zurb.com/docs/components/forms.html) for working with forms. Unfortunately, using them with Rails can be a bit of a hassle, as Foundation wants each form input to be wrapped in a `<div>`, with another `<div>` for errors.
10
10
 
11
- In addition, I wanted to use something like [Formtastic](http://github.com/justinfrench/formtastic) to DRY up my form field markup, but writing new renderers for Formtastic is non-trivial, and I wanted something a bit simpler anyway, so I rolled my own.
11
+ In addition, I wanted to use something like [Formtastic](http://github.com/justinfrench/formtastic) to DRY up my form field markup, but writing new renderers for Formtastic is non-trivial, and I wanted something a bit simpler anyway, so I rolled my own. If you want to build pretty forms with a simple `FormBuilder` interface and all the Foundation goodness, this gem is for you!
12
12
 
13
- This gem is a work in progress. I welcome bug reports and pull requests! It's only tested on Rails 4.2 and Ruby 2.2 so far, but I'd love to support older versions of both Rails and Ruby if it's not too difficult to do so.
13
+ FoundationFormBuilder is a work in progress. I welcome bug reports and pull requests! It's only tested on Rails 4.2 and Ruby 2.2 so far, but I'd love to support older versions of both Rails and Ruby if it's not too difficult to do so.
14
14
 
15
15
  ## Sounds great! How do I use it?
16
16
 
17
- Install the gem:
17
+ Install the gem in the usual way:
18
18
  ```ruby
19
- gem install foundation_form_builder
19
+ gem 'foundation_form_builder'
20
20
  ```
21
21
  Then put the following in your `application.rb` file:
22
22
  ```ruby
@@ -43,22 +43,37 @@ will create something like
43
43
  </form>
44
44
  ```
45
45
 
46
- Note that `FoundationFormBuilder::Rails` uses the Rails form helper functions to render the fields, and that it is somewhat smart in its choice of helpers. It uses `email_field` automatically if the name of the field is `email`; similarly, it uses `password_field` for any field whose name *contains* `password`. If the name of the field is `time_zone`, it renders a Rails `time_zone_select`. If the field corresponds to a `text` column in the database, it calls `text_area`; for a `date` column, it uses `date_field`. Otherwise, a plain `text_field` is used.
46
+ Note that `FoundationFormBuilder::Rails` uses the Rails form helper functions to render the fields, and that it tries to infer the most appropriate form helper type, as follows.
47
47
 
48
+ | Condition | Default form helper |
49
+ | ---- | ---- |
50
+ | Field name is `email` | `email_field` |
51
+ | Field name is `time_zone` | `time_zone_select` |
52
+ | Field name contains the word `password` | `password_field` |
53
+ | Field maps to `date` column in DB | `date_field` |
54
+ | Field maps to `text` column in DB | `text_area` |
55
+ | Otherwise | `text_field` |
48
56
 
49
- Since `FoundationFormBuilder` is a subclass of the standard Rails `ActionView::Helpers::FormBuilder`, all the usual Rails `FormBuilder` helpers are also available. You'll probably need to use `f.submit` at least; we're not doing anything special with submit buttons at the moment.
57
+ Since `FoundationFormBuilder::Rails` is a subclass of the standard Rails `ActionView::Helpers::FormBuilder`, all the usual Rails `FormBuilder` helpers are also available. You'll probably need to use `f.submit` at least; we're not doing anything special with submit buttons at the moment.
50
58
 
51
59
  ### Advanced usage
52
60
 
53
- `input_div` takes several options if you want to override its defaults. `:label` overrides the label text, while `:type` overrides the inferred type (known values are `:date`, `:email`, `:password`, `:select`, `:textarea`, and `:time_zone`; anything else is understood as a text field). `:field` takes a hash of options which are passed through to the underlying Rails form helper.
61
+ `input_div` takes several options if you want to override its defaults.
54
62
 
55
- If `type: :select` is specified, then the values for the `select`options must be specified in `:values`, like this:
63
+ | Option | Value |
64
+ | ------ | ------ |
65
+ | `:field` | Hash of options to pass through to the underlying Rails form helper |
66
+ | `:label` | Text for label |
67
+ | `:type` | Explicit form helper type; overrides inferred types (see above). Significant values are `:date`, `:email`, `:password`, `:select`, `:textarea`, and `:time_zone`; `:text` or anything else will generate a text field. |
68
+ | `:values` | Values for `<option>` elements; only meaningful with `type: :select`. |
69
+
70
+ The following example shows all of these options in use.
56
71
 
57
72
  ```ruby
58
73
  f.input_div :size, label: 'My size is:', type: :select, values: [['Small', 1], ['Large', 2]], field: {prompt: 'Choose a size'}
59
74
  ```
60
75
 
61
- which produces:
76
+ It renders as:
62
77
  ```html
63
78
  <div class='size'>
64
79
  <label for='product_size'>My size is:</label>
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = "exe"
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
+ spec.required_ruby_version = '>= 2.0'
25
26
 
26
27
  [
27
28
  ['actionview', '>= 4.2.0'],
@@ -1,3 +1,3 @@
1
1
  module FoundationFormBuilder
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foundation_form_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marnen Laibow-Koser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: '2.0'
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - ">="