Sha256: d28e9fb7d171a5d40bc76ee3632bb3d4571d2a8c55c34818e110bcc2eb7ae58b

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

<%#
# HasOne Form Partial

This partial renders an input element for has_one relationships.

The form will be rendered as nested_from to parent relationship.

## Local variables:

- `f`:
  A Rails form generator, used to help create the appropriate input fields.
- `field`:
  An instance of [Administrate::Field::HasOne][1].
  A wrapper around the has_one relationship pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasOne
%>

<%= f.fields_for field.attribute, field.data || field.nested_form.resource.class.new do |has_one_f| %>
  <fieldset class="field-unit--nested">
    <legend><%= t "helpers.label.#{f.object_name}.#{field.name}", default: field.name.titleize %></legend>
    <% field.nested_form.attributes.each do |title, attributes| -%>

      <fieldset class="<%= "field-unit--nested" if title.present? %>">
        <% if title.present? %>
          <legend><%= t "helpers.label.#{f.object_name}.#{title}", default: title %></legend>
        <% end %>

        <% attributes.each do |attribute| %>
          <div class="field-unit field-unit--<%= attribute.html_class %>">
            <%= render_field attribute, f: has_one_f %>
          </div>
        <% end %>
      </fieldset>

    <% end -%>
  </fieldset>
<% end %>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
administrate-1.0.0.beta3 app/views/fields/has_one/_form.html.erb
administrate-1.0.0.beta2 app/views/fields/has_one/_form.html.erb
administrate-1.0.0.beta1 app/views/fields/has_one/_form.html.erb
administrate-0.20.1 app/views/fields/has_one/_form.html.erb
administrate-0.20.0 app/views/fields/has_one/_form.html.erb