Sha256: 01479f6ad612f477091f200d2be501ee555c92cc1729481c1592c89ad94ed411

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

<%
  child_key = association[:child_key].first
  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="<%= 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>
                <% end %>
                <div>
                  <%= select(child_key, :collection => collection, :include_blank => true, :selected => selected.to_s, :label => label) %>
                  <p class="help">
                    <%= required ? "Required." : "Optional." %>
                  </p>
                </div>
              </div>
            </fieldset>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
merb-admin-0.6.2 app/views/main/_belongs_to.html.erb
merb-admin-0.6.1 app/views/main/_belongs_to.html.erb
merb-admin-0.6.0 app/views/main/_belongs_to.html.erb
merb-admin-0.5.7 app/views/main/_belongs_to.html.erb
merb-admin-0.5.6 app/views/main/_belongs_to.html.erb
merb-admin-0.5.5 app/views/main/_belongs_to.html.erb