Module: ErpForms::Extensions::ActiveRecord::HasDynamicForms::InstanceMethods

Defined in:
lib/erp_forms/extensions/active_record/has_dynamic_forms.rb

Instance Method Summary collapse

Instance Method Details

#default_formObject


47
48
49
# File 'lib/erp_forms/extensions/active_record/has_dynamic_forms.rb', line 47

def default_form        
  get_form
end

#formObject


34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/erp_forms/extensions/active_record/has_dynamic_forms.rb', line 34

def form
  unless self.dynamic_form.nil?
    return self.dynamic_form
  else
    current_form = default_form
    unless current_form.nil?
      return current_form
    else
      return new_form
    end
  end
end

#formsObject

get all forms by type


57
58
59
# File 'lib/erp_forms/extensions/active_record/has_dynamic_forms.rb', line 57

def forms
DynamicForm.find_all_by_model_name(self.class_name)
end

#get_form(internal_identifier = '') ⇒ Object

get active form by type and active columns


52
53
54
# File 'lib/erp_forms/extensions/active_record/has_dynamic_forms.rb', line 52

def get_form(internal_identifier='')
  self.dynamic_form = DynamicForm.get_form(self.class.to_s, internal_identifier)
end

#new_formObject


27
28
29
30
31
32
# File 'lib/erp_forms/extensions/active_record/has_dynamic_forms.rb', line 27

def new_form
  d = DynamicForm.new
  d.model_name = self.class.to_s
  d.dynamic_form_model_id = self.dynamic_form_model_id
  return self.dynamic_form = d        
end