1 <%= form_for(elm) do |f| %>
2 <% element_name = elm.class.to_s.underscore %>
3 <% model = @configurations['models'][element_name] %>
4 <% view = if model['extend'] %>
5 <% elm.attributes[model['extend']] %>
6 <% @configurations['forms'][elm.attributes[model['extend']]] %>
8 <% @configurations['forms'][element_name] %>
10 <% form = if view.is_a? String %>
11 <% @configurations['forms'][view] %>
15 <% form['fields'].each do |field_conf| %>
16 <% e = if field_conf['part'] %>
17 <% @configurations['models'][field_conf['part']] %>
21 <% column = field_conf['column'] %>
22 <% primary_key = e['attributes'][column]['primary_key'] %>
24 <% next if primary_key and elm.new_record? %>
26 <% options = field_conf['options'] || {} %>
28 <% form_model_name = if form['base'] %>
33 <% field_model_name = if field_conf['part'] %>
34 <% field_conf['part'] %>
38 <% field_elm = if field_conf['part'] %>
39 <% elm.__send__ field_conf['part'] %>
43 <% name = if field_conf['part'] %>
44 <% form_model_name + '[' + field_model_name + '_attributes][' + column + ']' %>
46 <% form_model_name + '[' + column + ']' %>
49 <% unless field_conf['type'] == 'hidden' %>
50 <%= t 'activerecord.attributes.' + field_model_name + '.' + column %>
52 <% if options['label_break'] %>
55 <% case field_conf['type'] %>
57 <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
58 <%= text_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
59 <% when 'text_area' %>
60 <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
61 <%= text_area_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
63 <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
64 <%= number_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
66 <%= hidden_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
68 <% items = case options['source'] %>
70 <% select_model = options['model'] %>
71 <% select_class = @configurations['models'][select_model]['class_name'] %>
72 <% l = select_class.constantize.__send__ options['method'] %>
73 <% l.map {|i| [i.attributes[options['caption']], i.id] } %>
74 <% when 'magic_number' %>
75 <% t_select_items(MagicNumber[options['key']]) %>
78 <%= select_tag name, options_for_select(items, field_elm.attributes[column]), field_elm.field_tag_attributes(column, no_attr) %>
80 <% if field_conf['helpers'] %>
81 <% field_conf['helpers'].each do |n, helper| %>
82 <% if helper['wrapper'] %>
83 <div class="<%= helper['wrapper'] -%>">
85 <%= render helper['path'], :elm => field_elm, :no_attr => no_attr, :opt => helper['options'] %>
86 <% if helper['wrapper'] %>
92 <% if options['row_break'] %>
93 <div class="row_break">