generic_form_builder 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjgxNTYzOGIzNjVkNGUwY2Q4MzA3ZjY4MzZkODY4MTliNTQ3MTRlNA==
4
+ NGI4Njc5YjcwNjk0NTQyYTk1Y2I2N2QwZDE3NjJmYmNkNGUzZWM0OQ==
5
5
  data.tar.gz: !binary |-
6
- OTM2OGY3MjI1MWE1N2U4MTc4MDliOTk2MTIxMGJkYzUwYWQ0YjU1YQ==
6
+ MjVjZWUxZDQ5ODM4ODEyY2MyMjg1NTRkZTY3MzRlYjQwNGQ2Mzc3NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTFjOGJiNTUwZjU5NzYzMzU4ZTRhMWNlOTc4ZGI3NWUwMDI1NzJkYWUxYjY0
10
- MjJmNzBhYzgyZmQwNzcxYmY4YmIzZWI0ZTJlZjQ3ZTg0ZDM1NGQ2NmM3MTVj
11
- YTJhMDQyYmFhMjEyYWNmMWUyN2Y1MGFmZThmMGQzNWY0N2IzNWQ=
9
+ M2VjNzY3N2NmNmI3NGViMDJlNzE3ZGQ5MGMwMjlkYTgzZjhlODczNzlhN2Ez
10
+ NGU5MGE2YTZiMDQ3MWNhNzhjNjY2ODc5YmUzY2YwNjFkOGVjMTJmZjZkZDNk
11
+ YzVjZjk2Yjc2MjU4MDQ0ZTg1Yjg5NGFkZDY4M2U2ZGM2YzY1OWI=
12
12
  data.tar.gz: !binary |-
13
- OGQzOGQ4NGZhZmJkMzU1NjllMDUxNTVjYTQzY2QyZmFmZjUwNTNlODA4ZGIz
14
- ODdkN2M4MmNmYjBhYTk5YTU0NTVhMjg5ZGJjZmY1N2JmMTFmZDFiOWEwZWRk
15
- NGNkZjNjMmMzMjA2MzNjMWU5NzVmOTNiYjBjZjk3NTVhZmMyM2Q=
13
+ ZDBlYjAzOTI3MGJjYjEzNzdhN2UzNDRjNjUzYTIyNjc3NmZkMGRkZDc3Nzcx
14
+ NjRhMWMzNzU1YzQ2NjZlMmY5MzkyYzQ0YzllMTBiNWViZDI3MDUwOTQxYzJj
15
+ MzA0YTgxMjViMzIwNmVhNzFiNjBmOTJkNzBiYjE5NjgzYTA0Y2Y=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "generic_form_builder"
4
- s.version = '0.11.0'
4
+ s.version = '0.12.0'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ["Elliot Crosby-McCullough", "George Brocklehurst", "Elise Huard", "Tom Stuart"]
7
7
  s.email = ["elliot.cm@gmail.com"]
@@ -1,7 +1,7 @@
1
1
  class GenericFormBuilder < ActionView::Helpers::FormBuilder
2
2
  include ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
3
3
 
4
- %w[
4
+ STANDARD_FIELDS = %w[
5
5
  text_field
6
6
  password_field
7
7
  text_area
@@ -9,7 +9,9 @@ class GenericFormBuilder < ActionView::Helpers::FormBuilder
9
9
  file_field
10
10
  number_field
11
11
  date_field
12
- ].each do |method|
12
+ ].freeze
13
+
14
+ STANDARD_FIELDS.each do |method|
13
15
  define_method(method.to_sym) do |field, *args|
14
16
  options, *args = args
15
17
  options ||= {}
@@ -17,13 +19,18 @@ class GenericFormBuilder < ActionView::Helpers::FormBuilder
17
19
  note = note_html(options[:note])
18
20
  button = ' '+content_tag(:button, content_tag(:span, options[:button])) if options[:button]
19
21
 
20
- html_options = {}
22
+ wrapper_html_options = options.delete(:wrapper_html_options) || {}
21
23
 
22
24
  if any_errors?(field)
23
- html_options.merge!('class' => 'errors')
25
+ wrapper_html_options.merge!('class' => 'errors')
24
26
  end
25
27
 
26
- content_tag(:p, label(field, "#{options[:label] || field.to_s.humanize} #{errors_text(field)}".try(:html_safe)) + note + super(field, options, *args) + button.try(:html_safe), html_options)
28
+ content_tag(:p,
29
+ label(field, "#{options[:label] || field.to_s.humanize} #{errors_text(field)}".try(:html_safe)) +
30
+ note +
31
+ super(field, options, *args) +
32
+ button.try(:html_safe),
33
+ wrapper_html_options)
27
34
  end
28
35
  end
29
36
 
@@ -60,10 +67,19 @@ class GenericFormBuilder < ActionView::Helpers::FormBuilder
60
67
  end
61
68
 
62
69
  def buttons(options = {})
63
- buttons = content_tag(:button, content_tag(:span, options[:submit_text] || 'Save'), :type => 'submit')
64
- buttons << link_to('Cancel', options[:cancel_link], :class => 'cancel button') if options[:cancel_link]
65
-
66
- content_tag(:div, buttons, :class => 'actions')
70
+ options = {
71
+ cancel_class: ["cancel", "button"],
72
+ wrapper_class: ["actions"]
73
+ }.merge(options)
74
+
75
+ buttons = content_tag(:button,
76
+ content_tag(:span, options[:submit_text] || 'Save'),
77
+ type: 'submit',
78
+ class: options[:button_class]
79
+ )
80
+ buttons << link_to('Cancel', options[:cancel_link], class: options[:cancel_class]) if options[:cancel_link]
81
+
82
+ content_tag(:div, buttons, class: options[:wrapper_class])
67
83
  end
68
84
 
69
85
  protected
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generic_form_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Crosby-McCullough
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-01-22 00:00:00.000000000 Z
14
+ date: 2015-02-09 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description:
17
17
  email:
@@ -20,6 +20,7 @@ executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
+ - .gitignore
23
24
  - README.md
24
25
  - generic_form_builder.gemspec
25
26
  - lib/generic_form_builder.rb