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_render_input(column, options)
        record = options[:object]
        if (method = override_form_field(column))
          send(method, record, options)
        elsif column.form_ui && (method = override_input(column.form_ui))
          send(method, column, options)
        elsif column.association
          raise "Unknown form_ui `#{column.form_ui}' for column `#{column.name}'" if column.form_ui
          active_scaffold_input_select(column, options)
        elsif column.virtual?
          options[:value] = format_number_value(record.send(column.name), column.options) if column.number?
          active_scaffold_input_virtual(column, options)
        elsif (method = override_input(column.column.type)) 
          send(method, column, options)
        else 
          text_types = %i[text string integer float decimal]
          options = active_scaffold_input_text_options(options) if text_types.include?(column.column.type)
          if column.column.type == :string && options[:maxlength].blank?
            options[:maxlength] = column.column.limit
            options[:size] ||= options[:maxlength].to_i > 30 ? 30 : options[:maxlength]
          end
          options[:value] = format_number_value(record.send(column.name), column.options) if column.number?
          text_field(:record, column.name, options.merge(column.options).except(:format))
        end
      rescue StandardError => e
        logger.error "#{e.class.name}: #{e.message} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}"
        raise e
      end
def active_scaffold_render_input ( column , options ) record = options [ :object ] if ( method = override_form_field ( column ) ) send ( method , record , options ) elsif column . form_ui && ( method = override_input ( column . form_ui ) ) send ( method , column , options ) elsif column . association raise "Unknown form_ui `#{column.form_ui}' for column `#{column.name}'" if column . form_ui active_scaffold_input_select ( column , options ) elsif column . virtual? options [ :value ] = format_number_value ( record . send ( column . name ) , column . options ) if column . number? active_scaffold_input_virtual ( column , options ) elsif ( method = override_input ( column . column . type ) ) send ( method , column , options ) else text_types = %i[ text string integer float decimal ] options = active_scaffold_input_text_options ( options ) if text_types . include? ( column . column . type ) if column . column . type == :string && options [ :maxlength ] . blank? options [ :maxlength ] = column . column . limit options [ :size ] ||= options [ :maxlength ] . to_i > 30 ? 30 : options [ :maxlength ] end options [ :value ] = format_number_value ( record . send ( column . name ) , column . options ) if column . number? text_field ( :record , column . name , options . merge ( column . options ) . except ( :format ) ) end rescue StandardError => e logger . error "#{e.class.name}: #{e.message} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}" raise e end
This method decides which input to use for the given column.
This method decides which input to use for the given column .
# first, check if the dev has created an override for this specific field # second, check if the dev has specified a valid form_ui for this column # if we get here, it's because the column has a form_ui but not one ActiveScaffold knows about. # its an association and nothing is specified, we will assume form_ui :select # regular model attribute column # if we (or someone else) have created a custom render option for the column type, use that # final ultimate fallback: use rails' generic input method # for textual fields we pass different options
column
<not_specific>
options
<not_specific>