Changeset 920

Show
Ignore:
Timestamp:
11/09/07 08:25:30 (1 year ago)
Author:
iv..@gweezlebur.com
Message:

merb_helpers: allow radio_group_control to handle an array of options / Closes #285 / Thanks Bryan

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/merb_helpers/lib/form_helpers.rb

    r888 r920  
    103103      end 
    104104       
    105       def radio_group_control(col, options = {}, attrs = {}) 
     105      def radio_group_control(col, options = [], attrs = {}) 
    106106        errorify_field(attrs, col) 
    107107        val = @_obj.send(col) 
    108108        ret = "" 
    109109        options.each do |opt| 
    110           hash = {:name => "#{@_object_name}[#{col}]", :value => opt, :label => opt} 
    111           hash.merge!(:selected => "selected") if val.to_s == opt.to_s 
     110          value, label = opt.is_a?(Hash) ? [opt[:value], opt[:label]] : [opt, opt] 
     111          hash = {:name => "#{@_object_name}[#{col}]", :value => value, :label => label} 
     112          hash.merge!(:selected => "selected") if val.to_s == value.to_s 
    112113          ret << radio_field(hash) 
    113114        end