When there are no organizations defined and a harvest source is created, the forms gives an error, because no organization has been selected. I think this message is confusing, as there is no field for selecting such organization.
I would suggest showing a message if no organization is defined before submitting the form.
|
{% set show_organizations_selector = organizations_available and (user_is_sysadmin or dataset_is_draft) %} |
|
|
|
{% if show_organizations_selector %} |
|
{% set existing_org = data.owner_org %} |
|
<div class="control-group form-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 %}>{{ _('No 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> |
|
{% endif %} |
Instead of having only an if
, an else
could be created, with a link to define an organization, or some kind of help text. An empty readonly selector could also be shown.