<%= f.label a, class: "form-control-label #{required?(f.object, a).present? ? 'required' : ''}" %> <%= render 'slash_admin/shared/tooltip', a: a %> <% class_name_from_association = class_name_from_association(f.object, a) %> <%= f.collection_select a.to_s + '_id', class_name_from_association.constantize.all.order(f.object.send(a).present? ? Arel.sql("CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC") : "id DESC").limit(20), :id, object_label(a), { include_blank: true, }, 'data-placeholder': t('slash_admin.view.select_model', model_name: class_name_from_association.constantize.model_name.human.downcase), 'data-model': class_name_from_association.constantize.model_name.to_s.underscore, 'data-fields': "SlashAdmin::Models::#{a.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '), class: "form-control select2-model-single #{a.to_s}_id", required: required?(f.object, a).present? %> <%= t('slash_admin.view.add', model_name: class_name_from_association.constantize.model_name.human.downcase) %>