Sha256: 89bf11649a6fc09d8dcfd248d009c89e3f1a09eeb0a628f0e3b33e893802f04b

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

<% modelo = f.object.class.reflect_on_association(key.to_s).class_name.constantize %>
<% if f.object.present? && !f.object.send(key).present? %>
	<% if [:has_many,:has_and_belongs_to_many].include?(f.object.class.reflect_on_association(key).macro) %>
		<% f.object.send(key).build %>
	<% else %>
		<% f.object.send("build_#{key}") %>
	<% end %>
<% end %>
<%= f.simple_fields_for key do |g| %>
	<div class="col-sm-12">
		<h3><%= groups[:label] %></h3>
	</div>
	<% groups[:fields].each do |field| %>
		<% if field[:sf].present? && field[:sf][:grupo].present? %>
			<%= render "/crud/form_group", f: g, key: field[:attribute], groups: field[:sf] %>
		<% else %>
			<% if modelo.reflect_on_association(field[:attribute]).class == ActiveRecord::Reflection::BelongsToReflection && is_raro_crud(modelo.reflect_on_association(field[:attribute]).class_name) && field[:sf][:add_registro].nil?%>
					<%= render_plus_button(field,g,modelo,f.object) %>
			<%else%>
					<%= render_field(field,g,modelo,f.object) %>
			<%end%>
		<% end %>
	<% end %>
	<% if [:has_many,:has_and_belongs_to_many].include?(f.object.class.reflect_on_association(key).macro) %>
		<div class="form-group">
			<div class="col-sm-10 col-sm-offset-2">
				<%= g.link_to_remove "Remover #{groups[:label].downcase}" %>
			</div>
		</div>
	<% end %>
<% end %>
<% if [:has_many,:has_and_belongs_to_many].include?(f.object.class.reflect_on_association(key).macro) %>
	<div class="form-group">
		<div class="col-sm-12">
			<%= f.link_to_add "Adicionar #{groups[:label].downcase}", key %>
		</div>
	</div>
<% end %>

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
templus_models-1.5.2 app/views/crud/_form_group.html.erb
templus_models-1.5.1 app/views/crud/_form_group.html.erb
templus_models-1.5.0 app/views/crud/_form_group.html.erb
templus_models-1.4.4 app/views/crud/_form_group.html.erb
templus_models-1.4.3 app/views/crud/_form_group.html.erb
templus_models-1.4.2 app/views/crud/_form_group.html.erb
templus_models-1.4.1 app/views/crud/_form_group.html.erb
templus_models-1.4.0 app/views/crud/_form_group.html.erb
templus_models-1.3.9 app/views/crud/_form_group.html.erb
templus_models-1.3.8 app/views/crud/_form_group.html.erb