<commit_before>module Rubaidh #:nodoc:
  module FormHelper
    
    # def self.included(base)
    #   base.alias_method_chain :fields_for, :fieldset
    # end
    # 
    # # Behaves just like the regular +fields_for+ with a little extra magic
    # # juju in that it creates a fieldset around the fields inside.
    # def fields_for_with_fieldset(object_name, *args, &block)
    #   options = args.last.is_a?(Hash) ? args.pop : {}
    #   object  = args.first
    #   legend = options.delete(:legend) || object_name.to_s.humanize
    #   concat tag('fieldset', options, true), block.binding
    #   concat "<legend>#{legend}</legend>", block.binding
    #   fields_for_without_fieldset(object_name, object, options.merge(:builder => FormBuilder), &block)
    #   concat "</fieldset>", block.binding
    # end

    def label_for(object_name, method, options = {})
      ActionView::Helpers::InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_label_tag(options.delete(:label) || method.to_s.humanize, options)
    end

    def label_tag(name, text, options = {})
      content_tag('label', text, { 'for' => name }.merge(options.stringify_keys))
    end

    def fieldset(options, builder, &block)
      legend = options.delete(:legend)
      concat tag('fieldset', options, true), block.binding
      concat "<legend>#{legend}</legend>", block.binding unless legend.blank?
      block.call(builder)
      concat "</fieldset>", block.binding
    end
    
    def grouped_collection_select(object_name, method, collection, group_method, group_label_method, value_method, text_method, options = {}, html_options = {})
      ActionView::Helpers::InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_grouped_collection_select_tag(collection, group_method, group_label_method, value_method, text_method, options, html_options)
    end
  end

  module InstanceTag #:nodoc:
    def to_grouped_collection_select_tag(collection, group_method, group_label_method, value_method, text_method, options, html_options)<commit_msg>Update helper to work with rails 2.3<commit_after>module Rubaidh #:nodoc:
  module FormHelper
    
    # def self.included(base)
    #   base.alias_method_chain :fields_for, :fieldset
    # end
    # 
    # # Behaves just like the regular +fields_for+ with a little extra magic
    # # juju in that it creates a fieldset around the fields inside.
    # def fields_for_with_fieldset(object_name, *args, &block)
    #   options = args.last.is_a?(Hash) ? args.pop : {}
    #   object  = args.first
    #   legend = options.delete(:legend) || object_name.to_s.humanize
    #   concat tag('fieldset', options, true), block.binding
    #   concat "<legend>#{legend}</legend>", block.binding
    #   fields_for_without_fieldset(object_name, object, options.merge(:builder => FormBuilder), &block)
    #   concat "</fieldset>", block.binding
    # end

    def label_for(object_name, method, options = {})
      ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_label_tag(options.delete(:label) || method.to_s.humanize, options)
    end

    def label_tag(name, text, options = {})
      content_tag('label', text, { 'for' => name }.merge(options.stringify_keys))
    end

    def fieldset(options, builder, &block)
      legend = options.delete(:legend)
      concat tag('fieldset', options, true), block.binding
      concat "<legend>#{legend}</legend>", block.binding unless legend.blank?
      block.call(builder)
      concat "</fieldset>", block.binding
    end
    
    def grouped_collection_select(object_name, method, collection, group_method, group_label_method, value_method, text_method, options = {}, html_options = {})
      ActionView::Helpers::InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_grouped_collection_select_tag(collection, group_method, group_label_method, value_method, text_method, options, html_options)
    end
  end

  module InstanceTag #:nodoc:
    def to_grouped_collection_select_tag(collection, group_method, group_label_method, value_method, text_method, options, html_options)
{'fraction_non_alphanumeric': 0.1208313194780087, 'fraction_numerical': 0.0004833252779120348, 'mean_word_length': 4.232616940581543, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1849055', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1251, 'n_words': 282}