twitter-bootstrap-form-builder 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,10 +3,6 @@
3
3
  A gem for building **horizontal** (vertial/search/inline coming soon) Twitter Bootstrap forms, automagically handling the
4
4
  control-group markup, field labels and inline-error messages.
5
5
 
6
- ## Changes
7
-
8
- This fork displays error messages with .to_sentence instead of .join(',')
9
-
10
6
  ## Installation
11
7
 
12
8
  Add this line to your application's Gemfile:
@@ -21,6 +21,16 @@ module MNE
21
21
  end
22
22
  end
23
23
 
24
+ # Wrappers around the various *_fields method which include the markup needed
25
+ # to make a pretty Twitter Bootstrap form
26
+ #
27
+ # Options:
28
+ # :label => ...
29
+ # String - Specify the text of the label
30
+ # Array - Specify all arguments to pass to label_tag
31
+ # nil - No label, but maintain the rest of the Bootstrap markup
32
+ # false - Fallback to FormBuilder's implementation (no Bootstrap markup at all)
33
+ # :help_block => String - Add help sub-text to the field
24
34
  %w(text_field phone_field password_field email_field number_field file_field text_area select).each do |method_name|
25
35
  define_method method_name.to_sym do |field, *args|
26
36
 
@@ -49,6 +59,10 @@ module MNE
49
59
 
50
60
 
51
61
  # Special handling for check boxes, which can have two labels
62
+ #
63
+ # Options
64
+ # :label - As the *_field methods
65
+ # :text - Like :label but for the right-hand label
52
66
  def check_box(field, options = {}, checked_value = "1", unchecked_value = "0")
53
67
  label_tag = build_label_tag(field, options)
54
68
 
@@ -76,6 +90,24 @@ module MNE
76
90
  end.html_safe
77
91
  end
78
92
 
93
+ # Very light wrapper around FormBuilder#submit which adds a 'btn' class
94
+ #
95
+ # Options:
96
+ # :label => false - fall back to FormBuilder#submit
97
+ # :primary => true - add btn-primary class
98
+ def submit(value = nil, options = {})
99
+
100
+ if options[:label] === false
101
+ options.delete(:label)
102
+ return super
103
+ end
104
+
105
+ options[:class] = "#{options[:class]} btn"
106
+ options[:class] = "#{options[:class]} btn-primary" if options.delete(:primary)
107
+
108
+ super(value, options)
109
+ end
110
+
79
111
  protected
80
112
 
81
113
  def extract_options(args)
@@ -1,5 +1,5 @@
1
1
  module MNE
2
2
  module TwitterBootstrapFormBuilder
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 6
9
- version: 0.0.6
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matthew Eagar