app/views/main/_belongs_to.html.erb in merb-admin-0.5.4 vs app/views/main/_belongs_to.html.erb in merb-admin-0.5.5
- old
+ new
@@ -1,19 +1,20 @@
<%
child_key = association[:child_key].first
- collection = MerbAdmin::AbstractModel.new(association[:parent_model]).all.map{|o| [o.id, object_title(o)]}.sort_by{|o| o[1]}
+ collection = MerbAdmin::AbstractModel.new(association[:parent_model]).all.map{|o| [o.id, object_name(o)]}.sort_by{|o| o[1]}
selected = @object.send(child_key)
label = association[:pretty_name]
required = false
+ errors_exist = !(@object.errors[child_key].nil? || @object.errors[child_key].empty?)
@properties.each do |property|
next unless property[:name] == child_key
required = true unless property[:nullable?]
end
%>
<fieldset class="module aligned">
<h2><%= label %></h2>
- <div class="<%= @object.errors[child_key] ? "form-row errors" : "form-row"%>">
- <% if @object.errors[child_key] %>
+ <div class="<%= errors_exist ? "form-row errors" : "form-row"%>">
+ <% if errors_exist %>
<ul class="errorlist">
<% @object.errors[child_key].each do |error| %>
<li><%= error %></li>
<% end %>
</ul>