Sha256: 62429f2a8937a288f22431d6afc88518bd615244916c7317f938627d48f46699

Contents?: true

Size: 1.3 KB

Versions: 11

Compression:

Stored size: 1.3 KB

Contents

<%
  child_key = association[:child_key].first
  association_name = association[:name]
  collection = MerbAdmin::AbstractModel.new(association[:child_model]).all.map{|o| [o.id, object_title(o)]}.sort_by{|o| o[1]}
  selected = @object.send(association_name)
  label = association[:pretty_name]
  required = false
  @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] %>
                <ul class="errorlist">
                  <% @object.errors[child_key].each do |error| %>
                  <li><%= error %></li>
                  <% end %>
                </ul>
                <% end %>
                <div>
                  <%= select(:name => "associations[#{association_name}][]", :id => association_name, :collection => collection, :include_blank => true, :selected => selected ? selected.id.to_s : nil, :label => label) %>
                  <p class="help">
                    <%= required ? "Required." : "Optional." %>
                  </p>
                </div>
              </div>
            </fieldset>

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
merb-admin-0.5.4 app/views/main/_has_one.html.erb
merb-admin-0.5.3 app/views/main/_has_one.html.erb
merb-admin-0.5.2 app/views/main/_has_one.html.erb
merb-admin-0.5.1 app/views/main/_has_one.html.erb
merb-admin-0.5.0 app/views/main/_has_one.html.erb
merb-admin-0.4.9 app/views/main/_has_one.html.erb
merb-admin-0.4.8 app/views/main/_has_one.html.erb
merb-admin-0.4.7 app/views/main/_has_one.html.erb
merb-admin-0.4.6 app/views/main/_has_one.html.erb
merb-admin-0.4.5 app/views/main/_has_one.html.erb
merb-admin-0.4.4 app/views/main/_has_one.html.erb