Sha256: 2e9a80886838b1268ac93cd2918f540a2f2f4a0e2b0d7110ca3548b54263f811

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

<% @model.form_attributes.each do |entries| %>
<% entries.each do |attribute, properties| %>

	<% if properties["type"] == "wysiwyg_field" %>
		<% type = properties["type"] %>
		<% args = properties.except("type", "name") %>
		<%= f.hidden_field attribute, :id => "#{attribute}-field", :value => resource.send(attribute) %>
		<%= f.send(type, attribute, args) %>
		<%= content_for :scripts do %>
			<script type="text/javascript">
			<%= render "shared/init_editor", :field_var => attribute, :label => properties[:label] %>
			</script>
		<% end %>

	<% elsif properties["type"] == "adminpanel_file_field" %>
		<%= f.fields_for :images do |builder| %>
    	<%= render 'shared/image_fields', :f => builder, :model_name => @model.display_name.capitalize %>
  	<% end -%>
  	<%= link_to_add_fields t("Add Image"), f, :images, @model.display_name.capitalize %>

  <% elsif properties["type"] == "belongs_to" %>
		<% args = properties.except("type", "name", "model") %>
		<% args.symbolize_keys! %>
  	<%= f.select(attribute, (@collections["#{properties["model"]}"].collect{|resource| [resource.name, resource.id]}), args) %>

  <% elsif properties["type"] == "has_many" %>
		<%= 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 %>

  <% else %>
		<% type = properties["type"] %>
		<% args = properties.except("type", "name") %>
    <%= f.send(type, attribute, args) %>
  <% end %>

<% end %>
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adminpanel-1.2.5 app/views/shared/_form_fields.html.erb