app/models/data_field.rb
#This should probably be moved to the data_entries helper
#Based on the display type, returns the arguments for the formhelper methods
This should probably be moved to the data_entries helper
Based on the display type, returns the arguments for the formhelper methods
This should probably be moved to the data_entries helper Based on the display type returns the arguments for the formhelper methods
def prepare_form_helpers
    if display_type == "text_field"
      return ["data_fields", id, {id: id}]
    elsif display_type == "text_area"
      return ["data_fields", id]
    elsif display_type == "select"
      options = values.split(',').each{|opt| opt.squish!}
      return ["data_fields", id, options.map{|opt| [opt, opt]}]
    elsif display_type == "check_box"
      options = values.split(',').each{|opt| opt.squish!}
      return options.map{|v| ["data_fields[#{id}]", v]}
    elsif display_type == "radio_button"
      options = values.split(',').each{|opt| opt.squish!}
      return options.map{|v| ["data_fields[#{id}]", 1, v]}
    end
  end
def prepare_form_helpers if display_type == "text_field" return [ "data_fields" , id , { id : id } ] elsif display_type == "text_area" return [ "data_fields" , id ] elsif display_type == "select" options = values . split ( ',' ) . each { | opt | opt . squish! } return [ "data_fields" , id , options . map { | opt | [ opt , opt ] } ] elsif display_type == "check_box" options = values . split ( ',' ) . each { | opt | opt . squish! } return options . map { | v | [ "data_fields[#{id}]" , v ] } elsif display_type == "radio_button" options = values . split ( ',' ) . each { | opt | opt . squish! } return options . map { | v | [ "data_fields[#{id}]" , 1 , v ] } end end
This should probably be moved to the data_entries helper
Based on the display type, returns the arguments for the formhelper methods
This should probably be moved to the data_entries helper Based on the display type returns the arguments for the formhelper methods