module Reform::Form::ActiveModel::FormBuilderMethods
Including FormBuilderMethods
will allow using form instances with form_for, simple_form, etc. in Rails. It will further try to translate Rails’ suboptimal songs_attributes weirdness back to normal ‘songs: ` naming in #valiate
.
Public Class Methods
included(base)
click to toggle source
# File lib/reform/form/active_model/form_builder_methods.rb, line 6 def self.included(base) base.extend ClassMethods # ::model_name end
Public Instance Methods
deserialize!(params)
click to toggle source
Modify the incoming Rails params hash to be representable compliant.
Calls superclass method
# File lib/reform/form/active_model/form_builder_methods.rb, line 27 def deserialize!(params) # this only happens in a Hash environment. other engines have to overwrite this method. schema.each do |dfn| rename_nested_param_for!(params, dfn) end super(params) end
Private Instance Methods
rename_nested_param_for!(params, dfn)
click to toggle source
# File lib/reform/form/active_model/form_builder_methods.rb, line 37 def rename_nested_param_for!(params, dfn) name = dfn[:name] nested_name = "#{name}_attributes" return unless params.has_key?(nested_name) value = params["#{name}_attributes"] value = value.values if dfn[:collection] params[name] = value end