def fill_form(hashtable, fields = [], map = {})
      hashtable, map = wrapper_hash(hashtable), wrapper_hash(map)

      fields = hashtable.keys.map(&:to_sym) if fields.empty?

      fields.each do |f|
        key = f
        key = map[f] if map.key?(f)

        el, val = send(f), hashtable[key]
        tag, it = el.send(:tag_name), el.send(:[], :type)

        if tag == 'input' && it == 'checkbox' # checkbox
          el.send(:set, val == 'true')
        elsif tag == 'select' # select
          el.send(:select, val)
        else
          el.send(:set, val)
        end
      end
    end
def fill_form(hashtable, fields = [], map = {})
      hashtable, map = wrapper_hash(hashtable), wrapper_hash(map)

      fields = hashtable.keys.map(&:to_sym) if fields.empty?

      fields.each do |f|
        key = f
        key = map[f] if map.key?(f)

        el, val = send(f), hashtable[key]
        tag, it = el.send(:tag_name), el.send(:[], :type)

        if tag == 'input' && it == 'checkbox' # checkbox
          el.send(:set, val == 'true')
        elsif tag == 'select' # select
          el.send(:select, val)
        else
          el.send(:set, val)
        end
      end
    end
usage:
 fill_form hashtable, [:id, :name], {:id => "id2"}
 fill_form hashtable, [], {:id => "id2"}
 fill_form hashtable
 if the fields is empty, it will use all the keys of the hashtable