Permalink
Browse files

Add crushyfield CSS class

  • Loading branch information...
1 parent c63fb87 commit c476b7a2b1dc5ef732de64aca4a1f5d90d75f015 @mig-hub committed May 12, 2011
Showing with 5 additions and 4 deletions.
  1. +1 −0 README.md
  2. +1 −1 lib/sequel_crushyform.rb
  3. +3 −3 test/spec_crushyform.rb
View
@@ -40,5 +40,6 @@ CSS CLASSES
-----------
- crushyfield-required is the class for the default required flag
+- crushyfield is used on the wrapping paragraph tag of every fields
- crushyfield-error is used on the wrapping paragraph tag of a field containing errors
- crushyfield-error-list is on the span that wraps the list of errors (is just a span, not an html list though)
View
@@ -106,7 +106,7 @@ def crushyform(columns=model.crushyform_schema.keys, action=nil, meth='POST')
def crushyfield(col, o={})
field_name = o[:name] || col.to_s.sub(/_id$/, '').tr('_', ' ').capitalize
error_list = errors.on(col).map{|e|" - #{e}"} if !errors.on(col).nil?
- "<p class='%s'><label for='%s'>%s</label><span class='crushyfield-error-list'>%s</span><br />\n%s</p>\n" % [error_list&&'crushyfield-error', crushyid_for(col), field_name, error_list, crushyinput(col, o)]
+ "<p class='crushyfield %s'><label for='%s'>%s</label><span class='crushyfield-error-list'>%s</span><br />\n%s</p>\n" % [error_list&&'crushyfield-error', crushyid_for(col), field_name, error_list, crushyinput(col, o)]
end
def crushyinput(col, o={})
o = model.crushyform_schema[col].dup.update(o)
View
@@ -320,12 +320,12 @@ class Attached < ::Sequel::Model
h = Haiku.new
h.valid?.should==false
h.crushyfield(:title).should.match(/<span class='crushyfield-error-list'> - is not good - smells like shit<\/span>/)
- h.crushyfield(:title).should.match(/^<p class='crushyfield-error'/)
+ h.crushyfield(:title).should.match(/^<p class='crushyfield crushyfield-error'/)
h.crushyfield(:body).should.match(/<span class='crushyfield-error-list'><\/span>/)
- h.crushyfield(:body).should.match(/^<p class=''/)
+ h.crushyfield(:body).should.match(/^<p class='crushyfield '/)
# Not validated
Haiku.new.crushyfield(:title).should.match(/<span class='crushyfield-error-list'><\/span>/)
- Haiku.new.crushyfield(:title).should.match(/^<p class=''/)
+ Haiku.new.crushyfield(:title).should.match(/^<p class='crushyfield '/)
end
end

0 comments on commit c476b7a

Please sign in to comment.