--- /dev/null
+<% element_name = elm.element_name %>
+<% extend_element_name = elm.extend_element_name %>
+<% form_configurations = elm.find_configurations @configurations['forms'], extend_element_name %>
+<% base_attributes = if form_configurations['base'] %>
+ <% @configurations['forms'][form_configurations['base']]['attributes'] %>
+<% else %>
+ <% {} %>
+<% end %>
+<% extend_attributes = form_configurations['attributes'] || {} %>
+<% form_attributes = base_attributes.merge(extend_attributes) %>
+<% form_model_name = form_configurations['model'] || form_configurations['base'] || element_name %>
+<%= form_for(elm, :html => elm.tag_attributes('form', 'data-form-name' => extend_element_name)) do |f| %>
+ <% form_configurations['fields'].each do |field_name| %>
+ <% field_configurations = form_attributes[field_name] || {} %>
+ <% field_model_name = field_configurations['model'] || form_model_name %>
+ <% model_configurations = @configurations['models'][field_model_name] %>
+ <% column = field_configurations['column'] %>
+ <% model_configurations['attributes'] %>
+ <% primary_key = model_configurations['attributes'][column]['primary_key'] %>
+
+ <% next if primary_key and elm.new_record? %>
+
+ <% options = field_configurations['options'] || {} %>
+ <% opt = {} %>
+ <% opt.merge!('data-model' => field_model_name) %>
+ <% field_element = if field_configurations['part'] %>
+ <% elm.__send__ field_configurations['part'] %>
+ <% else %>
+ <% elm %>
+ <% end %>
+ <% name = if field_configurations['part'] %>
+ <% form_model_name + '[' + field_model_name + '_attributes][' + column + ']' %>
+ <% else %>
+ <% form_model_name + '[' + column + ']' %>
+ <% end %>
+ <div class="field">
+ <% label = field_configurations['label'] || {} %>
+ <% if label['type'] and label['type'] == 'hidden' %>
+ <% else %>
+ <%= t 'activerecord.attributes.' + field_model_name + '.' + column %>
+ <% end %>
+ <% if label['row_break'] %>
+ <br>
+ <% end %>
+ <% case field_configurations['type'] %>
+ <% when 'text' %>
+ <% opt['size'] = field_configurations['options']['size'] if field_configurations['options']['size'] %>
+ <%= text_field_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
+ <% when 'text_area' %>
+ <% opt['size'] = field_configurations['options']['size'] if field_configurations['options']['size'] %>
+ <%= text_area_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
+ <% when 'number' %>
+ <% opt['size'] = field_configurations['options']['size'] if field_configurations['options']['size'] %>
+ <%= number_field_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
+ <% when 'hidden' %>
+ <%= hidden_field_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
+ <% when 'select' %>
+ <% items = case options['source'] %>
+ <% when 'model' %>
+ <% select_model = options['model'] %>
+ <% select_class = @configurations['models'][select_model]['class_name'] %>
+ <% l = select_class.constantize.__send__ options['method'] %>
+ <% l.map {|i| [i.attributes[options['caption']], i.id] } %>
+ <% when 'magic_number' %>
+ <% t_select_items(MagicNumber[options['key']]) %>
+ <% else %>
+ <% end %>
+ <%= select_tag name, options_for_select(items, field_element.attributes[column]), field_element.field_tag_attributes(column, no_attr, opt) %>
+ <% end %>
+ <% if field_configurations['helpers'] %>
+ <% field_configurations['helpers'].each do |n, helper| %>
+ <% if helper['wrapper'] %>
+ <div class="<%= helper['wrapper'] -%>">
+ <% end %>
+ <%= render helper['path'], :elm => field_element, :no_attr => no_attr, :opt => helper['options'] %>
+ <% if helper['wrapper'] %>
+ </div>
+ <% end %>
+ <% end %>
+ <% end %>
+ </div>
+ <% if options['row_break'] %>
+ <div class="row_break">
+ </div>
+ <% end %>
+ <% end %>
+<% end %>