<%# The following params are the variables that can be used in this partial. @param form [Wallaby::FormBuilder] custom form object that adds a few helper methods and delegate missing methods to the view @param object [Wallaby::ResourceDecorator] decorator instance which wraps the resource (e.g. ActiveRecord) instance @param field_name [String] name of the field @param value [Object] value of the field @param metadata [Hash] metadata of the field %> <% decorated = decorate(value || []) readonly = unauthorized? :edit, metadata[:class] %>
<%= form.label metadata[:foreign_key], metadata[:label] %>
<% if readonly %>
<%= decorated.map(&:to_label).to_sentence %>
<% else %> <% wildcard = 'QUERY' url = remote_url(metadata[:remote_url], metadata[:class], wildcard) %>
<%= form.text_field metadata[:foreign_key], value: nil, class: 'form-control', multiple: true, placeholder: wt('labels.auto_select_hint') %>
<%= wt 'labels.count' %>
    <% decorated.each do |v| %>
  • <%= form.hidden_field metadata[:foreign_key], value: v.primary_key_value, multiple: true, id: nil %> <%= v.to_label %>
  • <% end %>
<% end %>
<%= form.error_messages field_name %> <%= hint_of metadata %>

<%= new_link metadata[:class] %>

<% #load script for only once unless @has_many_init @has_many_init = true content_for :custom_javascript do javascript_tag do %> documentReady('.has_many', function () { $('[data-init="has_many"]').auto_select(); }); <% end end end %>