foundation_form_builder 1.0.1 → 1.1.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 +2 -1
- data/lib/foundation_form_builder/rails.rb +9 -1
- data/lib/foundation_form_builder/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d71254250869b42e00acb5e91dcf036814280f14
|
4
|
+
data.tar.gz: 67c656d50440452b0e3ed7692d24bc30b6eab518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d242be3d4146734969d4c701d8be3e7a0ef39293cca8163d1ca640341d7bcae785060e2996b99248bd7a786a5ac6830c6fc81968bb11497db68201e58a311c45
|
7
|
+
data.tar.gz: 989a9325ba9fde3b0475c1952887daf8a7646445f35b953b7b9a7ad36a422b8800faafd3f0504940b60ff98784d41865b0e6d0f624fb18c391342e054939967c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -50,6 +50,7 @@ Note that `FoundationFormBuilder::Rails` uses the Rails form helper functions to
|
|
50
50
|
| Field name is `email` | `email_field` |
|
51
51
|
| Field name is `time_zone` | `time_zone_select` |
|
52
52
|
| Field name contains the word `password` | `password_field` |
|
53
|
+
| Field maps to numeric column in DB | `number_field` |
|
53
54
|
| Field maps to `date` column in DB | `date_field` |
|
54
55
|
| Field maps to `text` column in DB | `text_area` |
|
55
56
|
| Otherwise | `text_field` |
|
@@ -64,7 +65,7 @@ Since `FoundationFormBuilder::Rails` is a subclass of the standard Rails `Action
|
|
64
65
|
| ------ | ------ |
|
65
66
|
| `:field` | Hash of options to pass through to the underlying Rails form helper |
|
66
67
|
| `: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
|
+
| `:type` | Explicit form helper type; overrides inferred types (see above). Significant values are `:date`, `:email`, `:numeric`, `:password`, `:select`, `:textarea`, and `:time_zone`; `:text` or anything else will generate a text field. |
|
68
69
|
| `:values` | Values for `<option>` elements; only meaningful with `type: :select`. |
|
69
70
|
|
70
71
|
The following example shows all of these options in use.
|
@@ -67,6 +67,7 @@ module FoundationFormBuilder
|
|
67
67
|
method_mappings = {
|
68
68
|
date: :date_field,
|
69
69
|
email: :email_field,
|
70
|
+
numeric: :number_field,
|
70
71
|
password: :password_field,
|
71
72
|
textarea: :text_area,
|
72
73
|
}
|
@@ -91,7 +92,14 @@ module FoundationFormBuilder
|
|
91
92
|
type_mappings = {text: :textarea}
|
92
93
|
|
93
94
|
db_type = @object.column_for_attribute(field_name).type
|
94
|
-
|
95
|
+
case db_type
|
96
|
+
when :text
|
97
|
+
:textarea
|
98
|
+
when :decimal, :integer, :float
|
99
|
+
:numeric
|
100
|
+
else
|
101
|
+
db_type
|
102
|
+
end
|
95
103
|
end
|
96
104
|
end
|
97
105
|
end
|