Permalink
Browse files

Add an html class attribute for radio/checkbox labels in :as=>:radio …

…or :as=>:checkbox fields
  • Loading branch information...
1 parent e7cfa5f commit 27486eea87313331e77db92eed6e7c0ff69f045f @jeremyevans committed Aug 26, 2011
Showing with 29 additions and 27 deletions.
  1. +2 −0 CHANGELOG
  2. +4 −4 lib/sequel/plugins/forme.rb
  3. +23 −23 spec/sequel_plugin_spec.rb
View
@@ -1,5 +1,7 @@
=== HEAD
+* Add an html class attribute for radio/checkbox labels in :as=>:radio or :as=>:checkbox fields (jeremyevans)
+
* Wrap text acting as a label in a span with class label for :as=>:radio or :as=>:checkbox fields (jeremyevans)
* Support overriding the true/false label and values for select boolean fields in the Sequel plugin (jeremyevans)
@@ -304,7 +304,7 @@ def association_many_to_one(ref)
label = opts.delete(:label)
val = opts.delete(:value)
wrapper, tag_wrapper = get_wrappers
- radios = opts.delete(:options).map{|l, pk| _input(:radio, opts.merge(:value=>pk, :wrapper=>tag_wrapper, :label=>l, :checked=>(pk == val)))}
+ radios = opts.delete(:options).map{|l, pk| _input(:radio, opts.merge(:value=>pk, :wrapper=>tag_wrapper, :label=>l, :label_attr=>{:class=>:option}, :checked=>(pk == val)))}
add_label(label, radios)
wrapper ? wrapper.call(radios, _input(:radio, opts)) : radios
else
@@ -335,7 +335,7 @@ def association_one_to_many(ref)
label = opts.delete(:label)
val = opts.delete(:value)
wrapper, tag_wrapper = get_wrappers
- cbs = opts.delete(:options).map{|l, pk| _input(:checkbox, opts.merge(:value=>pk, :wrapper=>tag_wrapper, :label=>l, :checked=>val.include?(pk), :no_hidden=>true))}
+ cbs = opts.delete(:options).map{|l, pk| _input(:checkbox, opts.merge(:value=>pk, :wrapper=>tag_wrapper, :label=>l, :label_attr=>{:class=>:option}, :checked=>val.include?(pk), :no_hidden=>true))}
add_label(label, cbs)
wrapper ? wrapper.call(cbs, _input(:checkbox, opts)) : cbs
else
@@ -368,8 +368,8 @@ def input_boolean(sch)
case opts[:as]
when :radio
wrapper, tag_wrapper = get_wrappers
- true_opts = opts.merge(:value=>opts[:true_value]||'t', :label=>opts[:true_label]||'Yes', :error=>nil, :wrapper=>tag_wrapper, :wrapper_attr=>{})
- false_opts = opts.merge(:value=>opts[:false_value]||'f', :label=>opts[:false_label]||'No', :wrapper=>tag_wrapper, :wrapper_attr=>{})
+ true_opts = opts.merge(:value=>opts[:true_value]||'t', :label=>opts[:true_label]||'Yes', :label_attr=>{:class=>:option}, :error=>nil, :wrapper=>tag_wrapper, :wrapper_attr=>{})
+ false_opts = opts.merge(:value=>opts[:false_value]||'f', :label=>opts[:false_label]||'No', :label_attr=>{:class=>:option}, :wrapper=>tag_wrapper, :wrapper_attr=>{})
if i = opts[:id]
true_opts[:id] = "#{i}_yes"
false_opts[:id] = "#{i}_no"
Oops, something went wrong.

0 comments on commit 27486ee

Please sign in to comment.