module DefaultForm::ViewHelper

Public Instance Methods

form_object(record = nil, builder: DefaultForm::FormBuilder, **options) click to toggle source
# File lib/default_form/view_helper.rb, line 6
def form_object(record = nil, builder: DefaultForm::FormBuilder, **options)
  object_name = options[:scope].to_s

  if object_name.blank? && record.is_a?(ActiveRecord::Base)
    object_name = record.class.base_class.model_name.param_key
  end

  builder.new(object_name, record, self, options)
end
form_with(**options, &block) click to toggle source

theme: :default

Calls superclass method
# File lib/default_form/view_helper.rb, line 17
def form_with(**options, &block)
  if options[:theme].present? && options[:theme].end_with?('search')
    options[:url] = url_for unless options.key?(:url)
    options[:scope] = '' unless options.key?(:scope)
    options[:data] ||= {}
    options[:data][:action] = 'default_valid#filter'
  end

  super
end
xx_form_with(**options, &block) click to toggle source

todo support dynamic keys

# File lib/default_form/view_helper.rb, line 29
def xx_form_with(**options, &block)
  options[:model] = ActiveSupport::InheritableOptions.new(_values.symbolize_keys) unless options.key?(:model)

  form_with(**options, &block)
end