Sha256: b078ad65b0af470d45d3c8e504aab95dbdf63459afacaf28250594302c670ae4

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

<%#
# LazyBelongsTo Form Partial

This partial renders an input element for belongs_to relationships.
Instead of the default, this only loads the results lazily

## Local variables:

- `f`:
  A Rails form generator, used to help create the appropriate input fields.
- `field`:
  An instance of [Administrate::Field::LazyBelongsTo][1].
  A wrapper around the [Administrate::Field::BelongsTo][2] field

[1]: http://www.rubydoc.info/gems/administrate-field-lazy_belongs_to/Administrate/Field/LazyBelongsTo
[2]: http://www.rubydoc.info/gems/administrate/Administrate/Field/BelongsTo
%>

<div class="field-unit__label">
  <%= f.label field.permitted_attribute %>
</div>
<div class="field-unit__field"
     data-component="lazy-belongs-to"
     data-lazy-belongs-to="<%=
       {
         url: field.templated_action,
         value: field.value_attribute,
         label: field.label_attribute
       }.to_json
     %>"
>
  <%= f.hidden_field(field.permitted_attribute) %>

  <button type="button" disabled="disabled" class="button lazy_belongs_to__button"><%= field.current_value %></button>

  <div class="popout lazy_belongs_to__popout" data-target="popout">
    <input type="search" class="lazy_belongs_to__popout_search" placeholder="Search..." aria-label="Search input">
    <i class="icon">
      <svg width="18" height="18" viewBox="0 0 24 24" focusable="false" role="presentation">
        <path d="M16.436 15.085l3.94 4.01a1 1 0 0 1-1.425 1.402l-3.938-4.006a7.5 7.5 0 1 1 1.423-1.406zM10.5 16a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11z" fill="currentColor" fill-rule="evenodd"></path>
      </svg>
    </i>
    <output class="results" data-target="output">
      <select data-max-size="<%= field.size %>" aria-label="Select a result">
        <option></option>
      </select>
    </output>
  </div>
</div>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
administrate-field-lazy_belongs_to-0.2.0 app/views/fields/lazy_belongs_to/_form.html.erb