4 attr :manifest, :bucket_name, :use_name, :item, :mounted, :submit, :operators, :template_dir,
7 def self.factory bucket_or_form_name, use_name, item, mounted, submit, operators
8 bucket = LocalManifest.manifest.buckets[bucket_or_form_name]
9 c = if bucket and bucket.has_member?
14 c.new bucket_or_form_name, use_name, item, mounted, submit, operators
17 def initialize bucket_name, use_name, item, mounted, submit, operators
18 @bucket_name = bucket_name
23 @operators = operators
26 @manifest = LocalManifest.manifest.buckets[@bucket_name]
27 @template_dir = 'templates/r/form/'
30 @forms[@item.item_name] = Locmare::Form.new @item.item_name, @use_name, @item, @mounted, false, @operators
31 self.init_forms @item.item_name, @manifest, @item
35 def fold_extend_settings params
36 @item.class.fold_extend_settings params[@item.item_name]
37 self.members_fold_extend_settings @item, params[@item.item_name], @manifest
40 def members_fold_extend_settings fold_item, attr, man
41 man.members.each do |member_name, member_manifest|
42 member_item = fold_item.__send__ member_name
43 member_item.class.fold_extend_settings attr[member_name + '_attributes']
44 self.members_fold_extend_settings member_item, attr[member_name + '_attributes'], member_manifest
49 @form_fields.each do |form_field|
50 yield form_field.field_name, form_field
54 def push_form key, form_name, item
57 def init_forms key, man, item
58 man.members.each do |member_name, member_manifest|
59 form_name = member_name # write exchange function if you want
60 member_item = item.__send__(form_name)
61 new_key = key + '.' + form_name
62 @forms[new_key] = Locmare::Form.new new_key, member_item, @mounted, false, @operators
63 self.init_forms new_key, member_manifest, member_item
68 @manifest.form_field_names.each do |form_field_name|
69 r = form_field_name.form_name.blank? ? '' : '.' + form_field_name.form_name
70 key = @item.item_name + r
72 field = form.fields[form_field_name.field_name]
77 def template_file_name
82 self.template_dir + self.template_file_name
85 def fields_template_name
86 self.template_dir + 'fields'
95 @item.table_name + '.submit.new'
97 @item.table_name + '.submit.edit'
101 def submit_template_dir
102 self.template_dir + 'submit/'
105 def submit_template_name
107 self.submit_template_dir + 'submit'
109 self.submit_template_dir + 'none'