lib/active_scaffold/helpers/form_column_helpers.rb
# This method decides which input to use for the given column.
# It does not do any rendering. It only decides which method is responsible for rendering.
This method decides which input to use for the given column.
It does not do any rendering. It only decides which method is responsible for rendering.
This method decides which input to use for the given column . It does not do any rendering . It only decides which method is responsible for rendering .
def active_scaffold_new_record_subform(column, record, html_options, new_record_attributes: nil, locals: {}, skip_link: false) 
        klass =
          if column.association.polymorphic? && column.association.belongs_to?
            type = record.send(column.association.foreign_type)
            column.association.klass(record) if type.present? && (column.options[:add_new] == true || type.in?(column.options[:add_new]))
          else
            column.association.klass
          end
        return content_tag(:div, '') unless klass
        subform_attrs = active_scaffold_subform_attributes(column, nil, klass)
        if record.send(column.name)&.new_record?
          new_record = record.send(column.name)
        else
          subform_attrs[:style] = 'display: none'
        end
        subform_attrs[:class] << ' optional'
        scope = html_options[:name].scan(/record(.*)\[#{column.name}\]/).dig(0, 0)
        new_record ||= klass.new(new_record_attributes)
        locals = locals.reverse_merge(column: column, parent_record: record, associated: [], show_blank_record: new_record, scope: scope)
        subform = render(partial: subform_partial_for_column(column, klass), locals: locals)
        if column.options[:hide_subgroups]
          toggable_id = "#{sub_form_id(association: column.name, id: record.id || generated_id(record) || 99_999_999_999)}-div"
          subform << link_to_visibility_toggle(toggable_id, default_visible: false)
        end
        html = content_tag(:div, subform, subform_attrs)
        return html if skip_link
        html << active_scaffold_show_new_subform_link(column, record, html_options[:id], subform_attrs[:id])
      end
def active_scaffold_new_record_subform ( column , record , html_options , new_record_attributes : nil , locals : { } , skip_link : false ) klass = if column . association . polymorphic? && column . association . belongs_to? type = record . send ( column . association . foreign_type ) column . association . klass ( record ) if type . present? && ( column . options [ :add_new ] == true || type . in? ( column . options [ :add_new ] ) ) else column . association . klass end return content_tag ( :div , '' ) unless klass subform_attrs = active_scaffold_subform_attributes ( column , nil , klass ) if record . send ( column . name ) &. new_record? new_record = record . send ( column . name ) else subform_attrs [ :style ] = 'display: none' end subform_attrs [ :class ] << ' optional' scope = html_options [ :name ] . scan ( / record(.*) \[ #{ column . name } \] / ) . dig ( 0 , 0 ) new_record ||= klass . new ( new_record_attributes ) locals = locals . reverse_merge ( column : column , parent_record : record , associated : [ ] , show_blank_record : new_record , scope : scope ) subform = render ( partial : subform_partial_for_column ( column , klass ) , locals : locals ) if column . options [ :hide_subgroups ] toggable_id = "#{sub_form_id(association: column.name, id: record.id || generated_id(record) || 99_999_999_999)}-div" subform << link_to_visibility_toggle ( toggable_id , default_visible : false ) end html = content_tag ( :div , subform , subform_attrs ) return html if skip_link html << active_scaffold_show_new_subform_link ( column , record , html_options [ :id ] , subform_attrs [ :id ] ) end
This method decides which input to use for the given column.
This method decides which input to use for the given column .
# rubocop:disable Metrics/ParameterLists
column
<not_specific>
record
<not_specific>
html_options
<not_specific>
new_record_attributes
<not_specific>
locals
<not_specific>
skip_link
<not_specific>