-<%= form_for(elm) do |f| %>
- <% element_name = elm.class.to_s.underscore %>
- <% model = @configurations['models'][element_name] %>
- <% view = if model['extend'] %>
- <% elm.attributes[model['extend']] %>
- <% @configurations['forms'][elm.attributes[model['extend']]] %>
- <% else %>
- <% @configurations['forms'][element_name] %>
- <% end %>
- <% form = if view.is_a? String %>
- <% @configurations['forms'][view] %>
- <% else %>
- <% view %>
- <% end %>
- <% form['fields'].each do |field_conf| %>
- <% e = if field_conf['part'] %>
- <% @configurations['models'][field_conf['part']] %>
- <% else %>
- <% model %>
- <% end %>
- <% column = field_conf['column'] %>
- <% primary_key = e['attributes'][column]['primary_key'] %>
+<% element_name = elm.element_name %>
+<% extend_element_name = elm.extend_element_name %>
+<% form_configurations = Pettanr::Application::manifest.profiler_managers[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_conf['options'] || {} %>
+ <% options = field_configurations['options'] || {} %>
<% opt = {} %>
- <% form_model_name = if form['base'] %>
- <% form['base'] %>
- <% else %>
- <% element_name %>
- <% end %>
- <% field_model_name = if field_conf['part'] %>
- <% field_conf['part'] %>
- <% else %>
- <% form_model_name %>
- <% end %>
- <% field_elm = if field_conf['part'] %>
- <% elm.__send__ field_conf['part'] %>
+ <% opt.merge!('data-model' => field_model_name) %>
+ <% field_element = if field_configurations['part'] %>
+ <% elm.__send__ field_configurations['part'] %>
<% else %>
<% elm %>
<% end %>
- <% name = if field_conf['part'] %>
+ <% name = if field_configurations['part'] %>
<% form_model_name + '[' + field_model_name + '_attributes][' + column + ']' %>
<% else %>
<% form_model_name + '[' + column + ']' %>
<% end %>
<div class="field">
- <% unless field_conf['type'] == 'hidden' %>
+ <% label = field_configurations['label'] || {} %>
+ <% if label['type'] and label['type'] == 'hidden' %>
+ <% else %>
<%= t 'activerecord.attributes.' + field_model_name + '.' + column %>
<% end %>
- <% if options['label_break'] %>
+ <% if label['row_break'] %>
<br>
<% end %>
- <% case field_conf['type'] %>
+ <% case field_configurations['type'] %>
<% when 'text' %>
- <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
- <%= text_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+ <% 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_conf['options']['size'] if field_conf['options']['size'] %>
- <%= text_area_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+ <% 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_conf['options']['size'] if field_conf['options']['size'] %>
- <%= number_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+ <% 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_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+ <%= 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' %>
<% t_select_items(MagicNumber[options['key']]) %>
<% else %>
<% end %>
- <%= select_tag name, options_for_select(items, field_elm.attributes[column]), field_elm.field_tag_attributes(column, no_attr) %>
+ <%= select_tag name, options_for_select(items, field_element.attributes[column]), field_element.field_tag_attributes(column, no_attr, opt) %>
<% end %>
- <% if field_conf['helpers'] %>
- <% field_conf['helpers'].each do |n, helper| %>
- <% if helper['wrapper'] %>
- <div class="<%= helper['wrapper'] -%>">
+ <% if field_configurations['helpers'] %>
+ <span id="<%= elm.tag_id '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 %>
- <%= render helper['path'], :elm => field_elm, :no_attr => no_attr, :opt => helper['options'] %>
- <% if helper['wrapper'] %>
- </div>
- <% end %>
- <% end %>
+ </span>
<% end %>
</div>
<% if options['row_break'] %>