Sha256: 84efe52dbbae535a3087560e7d4a5eb6c86cdf476ccbd757a7566b55adb93cde

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

<%#=
  render :partial => "layouts/form_habtm_tag", :locals => {
    :model_class => @product,
    :model_name => "product",
    :plural_model_name => "products",
    :linked_model_name => "tag",
    :plural_linked_model_name => "tags",
    :namespace_bs => "admin",
    :engine_bs => "YOUR_ENGINE_OR_EMPTY_STRING",
    :field_to_search_for_linked_model => "name",
    :attr_to_show => "caption",
    :f => f
  }
  # Example to put in a _form.html.erb
%>
<% path_namespace = "/" %>
<% path_namespace += "#{engine_bs}/" if engine_bs.present? %>
<% path_namespace += "/#{namespace_bs}/" if namespace_bs.present? %>

<div class="form-group">
    <%= f.label plural_linked_model_name.to_sym, t(plural_linked_model_name.to_sym, :default => plural_linked_model_name.capitalize), :class => "control-label" %>
    <div>
        <select multiple="multiple" class="form-control bs-tagit" id="<%= model_name %>_<%= linked_model_name %>_ids" name="<%= model_name %>[<%= linked_model_name %>_ids][]"  data-tags="true" data-placeholder="<%= t('select-an-option', default: 'Select an option') %>" data-allow-clear="true" data-ajax--cache="true" data-ajax--url="<%= path_namespace %><%= plural_linked_model_name %>/search_and_filter.json" data-param="q[<%= field_to_search_for_linked_model %>_cont]" data-result="<%= attr_to_show %>">
          <% begin %>
            <% for elt in model_class.send(plural_linked_model_name) %>
            <option selected="selected" data-value="<%= elt.id %>"><%= elt.caption %></option>
            <% end %>
          <% rescue %>
          <% end %>
        </select>
    </div>
</div>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
beautiful_scaffold-2.0.3 lib/generators/templates/app/views/_form_habtm_tag.html.erb