Sha256: 174256f5388434e292d37ba7e0b1ca544275e705da287654137d57b5e9d73185

Contents?: true

Size: 1.62 KB

Versions: 6

Compression:

Stored size: 1.62 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" %>
    	<%= 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

6 entries across 6 versions & 1 rubygems

Version Path
adminpanel-1.2.4 app/views/shared/_form_fields.html.erb
adminpanel-1.2.3 app/views/shared/_form_fields.html.erb
adminpanel-1.2.2 app/views/shared/_form_fields.html.erb
adminpanel-1.2.1 app/views/shared/_form_fields.html.erb
adminpanel-1.2.0 app/views/shared/_form_fields.html.erb
adminpanel-1.1.0 app/views/shared/_form_fields.html.erb