Sha256: 31f688474dc448ccfee56cf0be5625a8632cad18edce47edd009decc9e5c98d9

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 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[:sublabel] || groups[:label] || I18n.t("simple_form.labels.#{modelo.name.underscore}.#{key}") %></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]).try(:macro) == :belongs_to && 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[:sublabel] || groups[:label].try(:downcase) || I18n.t("simple_form.labels.#{modelo.name.underscore}.#{key}")}" %>
			</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[:sublabel] || groups[:label].try(:downcase) || I18n.t("simple_form.labels.#{modelo.name.underscore}.#{key}")}", key %>
		</div>
	</div>
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
templus_models-2.0.0 app/views/crud/_form_group.html.erb