midas-ul_form_builder 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,7 +1,13 @@
1
+ ==1.0.3 2009-03-12
2
+
3
+ * Added validation error handling.
4
+
5
+
1
6
  ==1.0.2 2009-03-12
2
7
 
3
8
  * Added dependency on midas-guilded >= 0.0.8
4
9
 
10
+
5
11
  == 1.0.1 2009-03-11
6
12
 
7
13
  * Initial release
@@ -5,7 +5,7 @@ require 'ul_form_builder/form_builders'
5
5
  require 'ul_form_builder/form_helpers'
6
6
 
7
7
  module UlFormBuilder
8
- VERSION = '1.0.2'
8
+ VERSION = '1.0.3'
9
9
  end
10
10
 
11
11
  if defined?( ActionView::Base )
@@ -27,12 +27,22 @@ module UlFormBuilder
27
27
  options.merge! :label => label unless options.has_key?( :label )
28
28
  options.merge!( :class => 'frm-standard' ) unless options.has_key?( :class )
29
29
  label = label( field, options[:label], :class => options.delete( :label_class ) )
30
- if self.object.class.respond_to?( :human_attribute_hint )
30
+
31
+ field_errors = self.object.errors.on( field.to_sym )
32
+
33
+ if field_errors
34
+ msg = field_errors.is_a?( Array ) ? field_errors.join( ', ' ) : field_errors
35
+ hint = @template.content_tag( :span, msg, :class => 'note' )
36
+ elsif self.object.class.respond_to?( :human_attribute_hint )
31
37
  hint = @template.content_tag( :span, self.object.class.human_attribute_hint( field.to_sym ), :class => 'note' )
32
38
  else
33
39
  hint = @template.content_tag( :span, (options[:hint] || ''), :class => 'note' )
34
40
  end
35
- @template.content_tag( :li, label + super( field, options ) + hint, :class => options[:li_class] ) #wrap with an li
41
+
42
+ classes = field_errors ? "highlight error" : ""
43
+ classes << " #{options[:li_class]}" unless options[:li_class].blank?
44
+
45
+ @template.content_tag( :li, label + super( field, options ) + hint, :class => classes ) #wrap with an li
36
46
  end
37
47
  end
38
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midas-ul_form_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Jason Harrelson (midas)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-12 00:00:00 -07:00
12
+ date: 2009-06-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.3
23
+ version: 1.3.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails