module Reform::Form::Prepopulate
prepopulate!(options) prepopulator: ->(model, user_options)
Public Instance Methods
prepopulate!(options = {})
click to toggle source
# File lib/reform/form/prepopulate.rb, line 4 def prepopulate!(options = {}) prepopulate_local!(options) # call #prepopulate! on local properties. prepopulate_nested!(options) # THEN call #prepopulate! on nested forms. self end
Private Instance Methods
prepopulate_local!(options)
click to toggle source
# File lib/reform/form/prepopulate.rb, line 13 def prepopulate_local!(options) schema.each do |dfn| next unless block = dfn[:prepopulator] ::Representable::Option(block).(exec_context: self, keyword_arguments: options) end end
prepopulate_nested!(options)
click to toggle source
# File lib/reform/form/prepopulate.rb, line 20 def prepopulate_nested!(options) schema.each(twin: true) do |dfn| Disposable::Twin::PropertyProcessor.new(dfn, self).() { |form| form.prepopulate!(options) } end end