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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +24 -9
- data/foundation_form_builder.gemspec +1 -0
- data/lib/foundation_form_builder/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ece24c8e1a79705694ac2d5695e29a54640772e7
|
4
|
+
data.tar.gz: a3faad3150a6b81023e7c96b9b4fc1ab4ebccc70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f01f5f4bf5e68adfc81b52741c4ccea267c062f1ba2f6993b90bc5b6f7b15da2fd0c2d6b2373b36b38e4db0f718ffd28eca50d44c476bd51dfd2021720da85d
|
7
|
+
data.tar.gz: 39110cabc23398f732511fce73733985b7304503309a8c5d5c894fe6c5c241d02e1409d7100072a0de0640ddeefad5bd76d4d679f61b9777e7ea4d7484b52dbe
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
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
|
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.
|
61
|
+
`input_div` takes several options if you want to override its defaults.
|
54
62
|
|
55
|
-
|
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
|
-
|
76
|
+
It renders as:
|
62
77
|
```html
|
63
78
|
<div class='size'>
|
64
79
|
<label for='product_size'>My size is:</label>
|
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.
|
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-
|
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
|
- - ">="
|