foundation_form_builder 0.3.0 → 0.3.1

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: ece24c8e1a79705694ac2d5695e29a54640772e7
4
- data.tar.gz: a3faad3150a6b81023e7c96b9b4fc1ab4ebccc70
3
+ metadata.gz: 51e1b678cf9389ebdd4be33ea71ddef5a9060b66
4
+ data.tar.gz: f6707a233e7a6c7e74f12b0f270e56078c03d5d9
5
5
  SHA512:
6
- metadata.gz: 6f01f5f4bf5e68adfc81b52741c4ccea267c062f1ba2f6993b90bc5b6f7b15da2fd0c2d6b2373b36b38e4db0f718ffd28eca50d44c476bd51dfd2021720da85d
7
- data.tar.gz: 39110cabc23398f732511fce73733985b7304503309a8c5d5c894fe6c5c241d02e1409d7100072a0de0640ddeefad5bd76d4d679f61b9777e7ea4d7484b52dbe
6
+ metadata.gz: 565073d1aef0d0142078b520b70327cb2dcede9f529f90f1c17c4b3b5abe24592bcc5b33c82fa4443873a1156ec73c48a07fbc0768e02caae2d5abd1431c9485
7
+ data.tar.gz: 22bb845a176c546359a60adf955bc46981306263bf5c852fd9d0fae44135414a0710cc5af5624f026682aa2d3d709a13446f353a389beeedb84bd0840ae052b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # FoundationFormBuilder changelog
2
2
 
3
+ # 0.3.1
4
+
5
+ 27 Feb 2015
6
+
7
+ Add some docstrings. [#2]
8
+
3
9
  # 0.3.0
4
10
 
5
11
  27 Feb 2015
@@ -4,6 +4,16 @@ require 'active_support/time_with_zone'
4
4
 
5
5
  module FoundationFormBuilder
6
6
  class Rails < ActionView::Helpers::FormBuilder
7
+
8
+ # Renders a form field with label wrapped in an appropriate +<div>+, with another +<div>+ for errors if necessary.
9
+ #
10
+ # @param field_name [String, Symbol] Name of the field to render
11
+ # @option options [Hash] :field Options to pass through to the underlying Rails form helper. For +type: :time_zone+, +:priority_zones+ is also understood.
12
+ # @option options [String, Symbol] :label (human-readable version of +field_name+) Text for the +<label>+ element
13
+ # @option options [Symbol] :type (type inferred by #infer_type) Type of field to render.
14
+ # Known values are +:date+, +:email+, +:password+, +:select+, +:textarea+, and +:time_zone+. Anything else is rendered as a text field.
15
+ # @option options [Array] :values Name-value pairs for +<option>+ elements. Only meaningful with +type: :select+.
16
+ # @return [SafeBuffer] The rendered HTML
7
17
  def input_div(field_name, label: nil, type: nil, values: nil, field: {})
8
18
  raise ArgumentError, ':values is only meaningful with type: :select' if values && type != :select
9
19
  @template.content_tag :div, class: field_name do
@@ -17,6 +27,10 @@ module FoundationFormBuilder
17
27
 
18
28
  private
19
29
 
30
+ # Renders a +<div>+ with errors if there are any for the specified field, or returns +nil+ if not.
31
+ #
32
+ # @param field_name [String, Symbol] Name of the field to check for errors
33
+ # @return [SafeBuffer, nil] The rendered HTML or nil
20
34
  def error_div(field_name)
21
35
  error_messages = errors[field_name]
22
36
  if error_messages.present?
@@ -55,6 +69,10 @@ module FoundationFormBuilder
55
69
  end
56
70
  end
57
71
 
72
+ # Infers the type of field to render based on the field name.
73
+ #
74
+ # @param [String, Symbol] the name of the field
75
+ # @return [Symbol] the inferred type
58
76
  def infer_type(field_name)
59
77
  case field_name
60
78
  when :email, :time_zone
@@ -1,3 +1,3 @@
1
1
  module FoundationFormBuilder
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foundation_form_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marnen Laibow-Koser