<commit_before>module Customly
  module ViewHelpers

    def custom_field_types
      Customly.configuration.field_types
    end

    def custom_field_tag(form, cfv, html_options = {})
      custom_field = cfv.custom_field
      label_text = custom_field.label
      
      ft = FieldType.find_by_key(custom_field.field_type)

      ft_html_options = ft.html_options || {}
      html_options[:class] = "#{ft_html_options.delete[:class]} #{html_options[:class]}" if html_options[:class] && ft_html_options[:class]
      html_options.merge!(ft_html_options)

      field = case ft.input_type
      when :text_field
        form.text_field :value, {value: cfv.value, required: custom_field.is_required?}.merge(html_options)

      when :select
        options = options_for_select(custom_field.options || [], (cfv.value || custom_field.default_value))
        form.select :value, options , {prompt: ""}, {required: custom_field.is_required?}.merge(html_options)

      end

      field + (form.hidden_field :custom_field_id, value: custom_field.id) + (form.hidden_field :id, value: cfv.id)
    end
  end
end<commit_msg>default custom_field_tag to text_field<commit_after>module Customly
  module ViewHelpers

    def custom_field_types
      Customly.configuration.field_types
    end

    def custom_field_tag(form, cfv, html_options = {})
      custom_field = cfv.custom_field
      label_text = custom_field.label
      
      ft = FieldType.find_by_key(custom_field.field_type)

      ft_html_options = ft.html_options || {}
      html_options[:class] = "#{ft_html_options.delete[:class]} #{html_options[:class]}" if html_options[:class] && ft_html_options[:class]
      html_options.merge!(ft_html_options)

      field = case ft.input_type
      when :select
        options = options_for_select(custom_field.options || [], (cfv.value || custom_field.default_value))
        form.select :value, options , {prompt: ""}, {required: custom_field.is_required?}.merge(html_options)
      else
        form.text_field :value, {value: cfv.value, required: custom_field.is_required?}.merge(html_options)        
      end

      field + (form.hidden_field :custom_field_id, value: custom_field.id) + (form.hidden_field :id, value: cfv.id)
    end
  end
end
{'fraction_non_alphanumeric': 0.11061750333185251, 'fraction_numerical': 0.0, 'mean_word_length': 3.701461377870564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7631758', 'n_tokens_mistral': 721, 'n_tokens_neox': 710, 'n_words': 127}