Method: Formotion::Form#render

Defined in:
lib/formotion/form/form.rb

#renderObject

A hashification with the user’s inputted values and row keys. EX …user plays with the Form…

> ‘[email protected]



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/formotion/form/form.rb', line 180

def render
  kv = {}
  self.sections.each {|section|
    if section.select_one?
      section.rows.each {|row|
        if row.value
          kv[section.key] = row.key
        end
      }
    else
      section.rows.each {|row|
        next if row.button?
        if row.templated?
          # If this row is part of a template
          # use the parent's key
          kv[row.template_parent.key] = row.template_parent.value
        else
          kv[row.key] ||= row.value_for_save_hash
        end
      }
    end
  }
  kv.merge! sub_render
  kv.delete_if {|k, v| k.nil? }
  kv
end