def multi_input_field(f, methods, options = {})
      raise ArgumentError.new('methods must respond to :count') unless methods.respond_to?(:count)

      options = {
          class:            'form-control',
          read_only:        false,
          attrib_val:       { },
          style:            { },
          input_group_size: ''
      }.merge(options)

      style = ''
      options[:style].each do |k,v|
        if k.to_s == 'width'
          options[:input_group_width] = "width: #{v};"
        else
          style += "#{k}: #{v};"
        end
      end

      options[:input_group_width] ||= 'width: 100%;'

      attrib = options[:attrib_val]
      attrib[:class] = options[:class]
      attrib[:readonly] = 'readonly' if options[:read_only]

      if options[:input_group_size] == 'sm' || options[:input_group_size] == 'small' || options[:input_group_size] == 'input-group-sm'
        options[:input_group_size] = 'input-group-sm'
      elsif options[:input_group_size] == 'lg' || options[:input_group_size] == 'large' || options[:input_group_size] == 'input-group-lg'
        options[:input_group_size] = 'input-group-lg'
      else
        options[:input_group_size] = ''
      end

      fld = []

      remaining_width = 100.0
      width = (100.0 / methods.count).round(2)

      builder = Proc.new do |method,label,index|
        num = index + 1
        # if user specified width, use it.
        width = options[:"width_#{num}"].to_s.to_f

        # otherwise compute the width.
        if width <= 0
          width = (remaining_width / (methods.count - index)).round(2)
          width = remaining_width if width > remaining_width || index == methods.count - 1
        end

        remaining_width -= width
        attrib[:style] = style + "width: #{width}%;"
        attrib[:value] = f.object.send(method)

        ph = options[:"placeholder_#{num}"] || (label.blank? ? method.to_s.humanize : label)
        attrib[:placeholder] = ph

        options.each do |opt_key, opt_val|
          attr_key,_,fld_num = opt_key.to_s.rpartition('_')
          if fld_num.to_i == num
            unless %w(value width placeholder).include?(attr_key)
              if %w(class style).include?(attr_key)
                attrib[:class] += ' ' + opt_val.to_s
              else
                attrib[attr_key.to_sym] = opt_val.to_s
              end
            end
          end
        end

        fld << f.text_field(method, attrib)
      end

      if methods.is_a?(Array)
        methods.each_with_index do |method, index|
          builder.call method, method.to_s.humanize, index
        end
      elsif methods.is_a?(Hash)
        methods.each_with_index do |(method,label), index|
          builder.call method, label.to_s, index
        end
      else
        raise ArgumentError.new('methods must either be an array or a hash')
      end

      "<div class=\"input-group #{options[:input_group_size]}\" style=\"#{options[:input_group_width]}\">#{fld.join}</div>".html_safe
    end
def multi_input_field(f, methods, options = {})
      raise ArgumentError.new('methods must respond to :count') unless methods.respond_to?(:count)

      options = {
          class:            'form-control',
          read_only:        false,
          attrib_val:       { },
          style:            { },
          input_group_size: ''
      }.merge(options)

      style = ''
      options[:style].each do |k,v|
        if k.to_s == 'width'
          options[:input_group_width] = "width: #{v};"
        else
          style += "#{k}: #{v};"
        end
      end

      options[:input_group_width] ||= 'width: 100%;'

      attrib = options[:attrib_val]
      attrib[:class] = options[:class]
      attrib[:readonly] = 'readonly' if options[:read_only]

      if options[:input_group_size] == 'sm' || options[:input_group_size] == 'small' || options[:input_group_size] == 'input-group-sm'
        options[:input_group_size] = 'input-group-sm'
      elsif options[:input_group_size] == 'lg' || options[:input_group_size] == 'large' || options[:input_group_size] == 'input-group-lg'
        options[:input_group_size] = 'input-group-lg'
      else
        options[:input_group_size] = ''
      end

      fld = []

      remaining_width = 100.0
      width = (100.0 / methods.count).round(2)

      builder = Proc.new do |method,label,index|
        num = index + 1
        # if user specified width, use it.
        width = options[:"width_#{num}"].to_s.to_f

        # otherwise compute the width.
        if width <= 0
          width = (remaining_width / (methods.count - index)).round(2)
          width = remaining_width if width > remaining_width || index == methods.count - 1
        end

        remaining_width -= width
        attrib[:style] = style + "width: #{width}%;"
        attrib[:value] = f.object.send(method)

        ph = options[:"placeholder_#{num}"] || (label.blank? ? method.to_s.humanize : label)
        attrib[:placeholder] = ph

        options.each do |opt_key, opt_val|
          attr_key,_,fld_num = opt_key.to_s.rpartition('_')
          if fld_num.to_i == num
            unless %w(value width placeholder).include?(attr_key)
              if %w(class style).include?(attr_key)
                attrib[:class] += ' ' + opt_val.to_s
              else
                attrib[attr_key.to_sym] = opt_val.to_s
              end
            end
          end
        end

        fld << f.text_field(method, attrib)
      end

      if methods.is_a?(Array)
        methods.each_with_index do |method, index|
          builder.call method, method.to_s.humanize, index
        end
      elsif methods.is_a?(Hash)
        methods.each_with_index do |(method,label), index|
          builder.call method, label.to_s, index
        end
      else
        raise ArgumentError.new('methods must either be an array or a hash')
      end

      "<div class=\"input-group #{options[:input_group_size]}\" style=\"#{options[:input_group_width]}\">#{fld.join}</div>".html_safe
    end
Creates an input group containing multiple input fields.

 Valid options:
 *   +input_group_size+
     Valid optional sizes are 'small' or 'large'.
 *   +readonly+
     Set to true to make the input field read only.
 *   +width+
     Set to any value to set the width of the overall field in percent.  Default is 100%.
 *   +width_1+ ... +width_N+
     Set the width of the child field to a specific percent. Defaults to equal amount for all children.
 *   +placeholder_1+ ... +placeholder_N+
     Set the placeholder of the child field.  Defaults to the method name.