formulate 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,8 @@ module Formulate
39
39
 
40
40
  def input(method, options={}, &block)
41
41
  type = options.delete(:type)
42
+ prefix = options.delete(:prefix)
43
+ suffix = options.delete(:suffix)
42
44
  instructions = options.delete(:instructions)
43
45
  errors = errors_on(method)
44
46
 
@@ -46,6 +48,7 @@ module Formulate
46
48
  classes << (options.delete(:required) ? 'required' : 'optional')
47
49
  classes << 'checkbox' if type == :check_box
48
50
  classes << 'radio' if type == :radio_button
51
+ classes << 'error' if errors.any?
49
52
  classes << options.delete(:class) if options[:class]
50
53
  classes.uniq!
51
54
 
@@ -87,7 +90,7 @@ module Formulate
87
90
  end unless block_given?
88
91
 
89
92
  label = options[:label] != false ? label(method, options[:label]) : nil
90
- markup = [label, input].compact
93
+ markup = [label, prefix, input, suffix].compact
91
94
  markup.reverse! if type.in?(:check_box, :radio_button)
92
95
 
93
96
  markup << @template.capture_haml do
@@ -1,9 +1,16 @@
1
1
  module Formulate
2
2
  module FormHelper
3
+ FIELD_ERROR_PROC = proc { |html_tag, instance_tag| html_tag }
4
+
3
5
  def form_for(record, options={}, &proc)
4
6
  options[:html] ||= {}
5
7
  options[:html][:class] ||= 'formulate'
8
+
9
+ original_field_error_proc = ::ActionView::Base.field_error_proc
10
+ ::ActionView::Base.field_error_proc = FIELD_ERROR_PROC
6
11
  super
12
+ ensure
13
+ ::ActionView::Base.field_error_proc = original_field_error_proc
7
14
  end
8
15
  end
9
16
  end
@@ -1,3 +1,3 @@
1
1
  module Formulate
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -73,6 +73,15 @@ form.formulate
73
73
  margin-right: 0.5em
74
74
  width: inherit
75
75
 
76
+ &.error
77
+ label
78
+ color: $error-color
79
+
80
+ input,
81
+ select,
82
+ textarea
83
+ border-color: $error-color
84
+
76
85
  p
77
86
  font-size: 0.875em
78
87
  font-style: italic
@@ -119,12 +128,3 @@ form.formulate
119
128
  li
120
129
  list-style: disc
121
130
  line-height: $line-height
122
-
123
- .field_with_errors
124
- label
125
- color: $error-color
126
-
127
- input,
128
- select,
129
- textarea
130
- border-color: $error-color
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formulate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-10 00:00:00.000000000 Z
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack