Method: Formotion::Form#values=

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

#values=(data) ⇒ Object Also known as: fill_out



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/formotion/form/form.rb', line 217

def values=(data)
  self.sections.each {|section|
    if section.select_one?
      # see if one of the select one value is used
      unless (section.rows.map{ |r| r.key } & data.keys).empty?
        section.rows.each { |row|
          row.value = data.has_key?(row.key) ? true : nil
        }
      end
    else
      section.rows.each {|row|
        next if row.button?
        if row.template_parent
          # If this row is part of a template
          # use the parent's key
          row.value = data[row.template_parent_key] if data.has_key?(row.template_parent_key)
        elsif row.subform
          row.subform.to_form.values = data
        else
          row.value = data[row.key] if data.has_key?(row.key)
        end
      }
    end
  }
end