<commit_before>module Para
  module FormHelper
    def para_form_for(resource, options = {}, &block)
      default_options = {
        as: :resource,
        wrapper: :horizontal_form,
        html: { class: '', data: { :'para-form' => true } }
      }

      options = default_options.deep_merge(options)

      options[:html][:class] = [
        options[:html][:class].presence,
        'form-horizontal form-group-separated'
      ].compact.join(' ')

      unless options.key?(:url)
        options[:url] = @component.relation_path(resource)
      end

      if options.fetch(:fixed_actions, true)
        default_options[:html][:class] << ' form-fixed-actions'
      end

      simple_form_for(resource, options, &block)
    end
  end
end
<commit_msg>append hidden field type to form for subclassable resources to avoid bad type instantiation on create<commit_after>module Para
  module FormHelper
    def para_form_for(resource, options = {}, &block)
      default_options = {
        as: :resource,
        wrapper: :horizontal_form,
        html: { class: '', data: { :'para-form' => true } }
      }

      options = default_options.deep_merge(options)

      options[:html][:class] = [
        options[:html][:class].presence,
        'form-horizontal form-group-separated'
      ].compact.join(' ')

      unless options.key?(:url)
        options[:url] = @component.relation_path(resource)
      end

      if options.fetch(:fixed_actions, true)
        default_options[:html][:class] << ' form-fixed-actions'
      end

      simple_form_for(resource, options) do |form|
        capture { block.call(form) }.tap do |content|
          # Append hidden field with type if resource is subclassable
          # to avoid bad class instantiation in create action
          if @component.subclassable? && resource.new_record?
            content << form.hidden_field(:type, value: resource.type)
          end
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11860940695296524, 'fraction_numerical': 0.0, 'mean_word_length': 2.5842490842490844, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1531962', 'n_tokens_mistral': 570, 'n_tokens_neox': 553, 'n_words': 132}