Skip to content

Instantly share code, notes, and snippets.

@dwcaraway
Created November 15, 2013 12:37
Show Gist options
  • Save dwcaraway/7483706 to your computer and use it in GitHub Desktop.
Save dwcaraway/7483706 to your computer and use it in GitHub Desktop.
{% if show_organizations_selector %}
{% set existing_org = data.owner_org %}
<div class="control-group">
<label for="field-organizations" class="control-label">{{ _('Organization') }}</label>
<div class="controls">
<select id="field-organizations" name="owner_org" data-module="autocomplete">
<option value="" {% if not selected_org and data.id %} selected="selected" {% endif %}>{{ _('Select an organization...') }}</option>
{% for organization in organizations_available %}
{# get out first org from users list only if there is not an existing org #}
{% set selected_org = (existing_org and existing_org == organization.id) or (not existing_org and not data.id and organization.id == organizations_available[0].id) %}
<option value="{{ organization.id }}" {% if selected_org %} selected="selected" {% endif %}>{{ organization.name }}</option>
{% endfor %}
</select>
</div>
</div>
{# private datasets must have an org, so add the owner_org tag in to pass validation #}
{% elif data.owner_org %}
<input type="hidden" name="owner_org" value="{{ data.owner_org }}"/>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment