{% if id_prefix+'_oid' in form_data %}
  {% set selected_id = form_data[id_prefix+'_oid'] %}
{% elif data is not none and "object_id" in data %}
  {% set selected_id = data.object_id | string %}
{% else %}
  {% set selected_id = None %}
{% endif %}
<div class="form-group{% if id_prefix+'_oid' in errors %} has-error{% elif id_prefix+'_oid' in form_data %} has-success{% endif %} row" style="padding-right:0.75em">
  <label class="control-label col-md-3 {% if schema.title and is_required %}required-label{% endif %}">{{ schema.title | get_translated_text }}</label>
  <div class="col-md-9">
      <select class="form-control selectpicker {% if selected_action is none %}objectpicker{% endif %}" name="{{ id_prefix }}_oid" data-none-selected-text="&mdash;" data-hide-disabled="true" data-live-search="true" {% if selected_action is none %}{% if selected_action_type is not none %}data-sampledb-valid-action-ids="{{ action_type_id_by_action_id.items() | selectattr(1, 'eq', selected_action_type) | map(attribute=0) | list | tojson }}"{% endif %}{% else %}data-sampledb-valid-action-ids="[{% if selected_action_type is not none and action_type_id_by_action_id[selected_action] != selected_action_type %}-1{% else %}{{ selected_action }}{% endif %}]"{% endif %} data-sampledb-default-selected="{{ selected_id }}" data-sampledb-required-perm="1">
        <option value="">&mdash;</option>
        {% if not referencable_objects and selected_id %}
            {% set referencable_objects = [get_object_if_current_user_has_read_permissions(selected_id | int)] %}
        {% endif %}
        {% for obj in referencable_objects %}
          {% if (action_type_id_by_action_id is none or selected_action_type is none or action_type_id_by_action_id[obj.action_id] == selected_action_type) and (selected_action is none or obj.action_id == selected_action) %}
            <option value="{{ obj.object_id }}" data-action-id="{{ obj.action_id }}" {% if selected_id == obj.object_id | string %}selected="selected"{% endif %} {% if 'tags' in obj.data and obj.data.tags._type == "tags" and obj.data.tags.tags %}data-tokens="{% for tag in obj.data.tags.tags %}#{{ tag }} {% endfor %}{{ obj.data['name']['text'] | get_translated_text }}"{% endif %}>{% if obj.data['name']['text'] | get_translated_text == '' %}&mdash;{% else %}{{ obj.data['name']['text'] | get_translated_text }}{% endif %} (#{{ obj.object_id }})</option>
          {% endif %}
        {% endfor %}
      </select>
      {% if selected_action is none %}
        <select class="selectpicker objectpicker-actionpicker" data-live-search="true" data-width="100%">
          <option selected="selected" value="">{{ _('All Actions') }}</option>
          {% for action in sorted_actions %}
            {% if selected_action_type is none or action.type_id == selected_action_type %}
          <option value="{{ action.id }}">
            {% if action.user is not none %}
              {{ action.user.name }} /
            {% endif %}
            {% if action.instrument is not none %}
              {{ action.instrument.translation.name }} &mdash;
            {% endif %}
            {{ action.translation.name }} (#{{ action.id }})
            {% endif %}
          </option>
          {% endfor %}
        </select>
      {% endif %}
    {% if id_prefix+'_oid' in object_errors %}<span class="help-block"><strong>{{ _('Error:') }}</strong> {{ object_errors[id_prefix+'_oid'] }}</span>{% endif %}
    {% if 'note' in schema %}<span class="help-block"><strong>{{ _('Note:') }}</strong> {{ schema['note'] | get_translated_text }}</span>{% endif %}
  </div>
</div>
