Overriding configuration_panel’s get_combobox_options endpoint call
# File lib/netzke/basepack/form_panel/services.rb, line 35
35: def configuration_panel__fields__get_combobox_options(params)
36: query = params[:query]
37: {:data => (default_columns.map{ |c| c[:name].to_s }).grep(/^#{query}/).map{ |n| [n] }}.to_nifty_json
38: end
Implementation for the “netzke_submit“ endpoint (for backward compatibility)
# File lib/netzke/basepack/form_panel/services.rb, line 50
50: def netzke_submit(params)
51: data = ActiveSupport::JSON.decode(params[:data])
52: success = create_or_update_record(data)
53:
54: if success
55: {:set_form_values => values, :set_result => "ok"}
56: else
57: # flash eventual errors
58: @record.errors.to_a.each do |msg|
59: flash :error => msg
60: end
61: {:feedback => @flash}
62: end
63: end
Creates/updates a record from hash
# File lib/netzke/basepack/form_panel/services.rb, line 68
68: def create_or_update_record(hsh)
69:
70: hsh.merge!(config[:strong_default_attrs]) if config[:strong_default_attrs]
71: @record ||= data_class.find(:first, :conditions => {data_class.primary_key => hsh.delete(data_class.primary_key)}) # only pick up the record specified in the params if it was not provided in the configuration
72: success = true
73:
74: @record = data_class.new if @record.nil?
75:
76: hsh.each_pair do |k,v|
77: @record.set_value_for_attribute(fields[k.to_sym].nil? ? {:name => k} : fields[k.to_sym], v)
78: end
79:
80: #hsh.each_pair do |k,v|
81: #begin
82: #@record.send("#{k}=",v)
83: #rescue StandardError => exc
84: #flash :error => exc.message
85: #success = false
86: #break
87: #end
88: #end
89:
90: # did we have complete success?
91: success && @record.save
92: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.