<% @model.form_attributes.each do |entries| %> <% entries.each do |attribute, properties| %> <% if properties["type"] == "wysiwyg_field" %> <% type = properties["type"] %> <% args = properties.except("type") %> <%= f.hidden_field attribute, :id => "#{attribute}-field", :value => resource.send(attribute) %> <%= f.send(type, attribute, args) %> <%= content_for :scripts do %> <% end %> <% elsif properties["type"] == "adminpanel_file_field" %> <% if !defined? remote_request %> <%= f.fields_for(attribute) do |builder| %> <%= render 'shared/image_fields', :f => builder %> <% end -%> <%= link_to_add_fields t("Add Image"), f, attribute %> <% end %> <% elsif properties["type"] == "belongs_to" %> <% if !defined? remote_request %> <% args = properties.except("type", "name", "model") %> <% args.symbolize_keys! %> <%= f.select(attribute, (@collections["#{properties["model"]}"].collect{|resource| [resource.name, resource.id]}), args) %> <% if(properties['remote_resource'].nil? || properties['remote_resource']) %> <% model_name = properties['model'].classify.constantize.model_name.demodulize.downcase %> <%= link_to( I18n.t('other.add', :model => properties['model'].classify.constantize.display_name ), polymorphic_path( [:new, :"#{model_name}"], :model => @model.display_name, :model_name => @model.name.demodulize.downcase, :belongs_request => true ), :class => 'btn btn-info', :id => "#{model_name}-modal-link", :'data-target' => "#new-modal", :'data-toggle' => 'modal', :remote => true ) %> <% end %> <% end %> <% elsif properties['type'] == 'has_many' %> <% if !defined? remote_request %>
<%= I18n.t('other.choose', :model => pluralize_es(properties['model'].classify.constantize.display_name)) %>
<%= hidden_field_tag("#{class_name_downcase(f.object)}[#{relationship_ids(properties["model"])}][]", nil) %>
<% @collections["#{properties['model']}"].each do |resource| %> <%= f.checkbox(resource, class_name_downcase(f.object) ,relationship_ids(properties["model"])) %> <% end %>
<% if properties['remote_resource'].nil? || propeties['remote_resource'] %> <% model_name = properties['model'].classify.constantize.model_name.demodulize.downcase %> <%= link_to( I18n.t('other.add', :model => properties['model'].classify.constantize.display_name ), polymorphic_path( [:new, :"#{model_name}"], :model => @model.display_name, :model_name => @model.name.demodulize.downcase ), :class => 'btn btn-info', :id => "#{model_name}-modal-link", :'data-target' => "#new-modal", :'data-toggle' => 'modal', :remote => true ) %> <% end %> <% end %> <% else %> <% type = properties["type"] %> <% args = properties.except("type", "name") %> <%= f.send(type, attribute, args) %> <% end %> <% end %> <% end %>