<% required = required ||= false %>
<% other_org = Org.find_by(is_other: true) %>
<% if f.object.errors[:org].present? %>
<div class="field_with_errors">
<% end %>
<%= f.label :org_name, _('Organisation'), class: 'control-label' %>
<% object_name = (f.options[:namespace].present? ? "#{f.options[:namespace]}_#{f.object_name}" : f.object_name) %>
<%= render partial: "shared/accessible_combobox",
locals: {name: "#{object_name}[org_name]",
id: "#{object_name}_org_name",
default_selection: default_org,
models: orgs,
attribute: 'name',
error: _('Please select an organisation from the list, or click the "My organisation isn\'t listed" link and enter your organisation\'s name.'),
required: required} %>
<% if f.object.errors[:org].present? %>
<div id="help-org" class="text-danger">
<%= _('Please select an organisation from the list, or click the "My organisation isn\'t listed" link and enter your organisation\'s name.') %>
</div>
<% end %>
<% if allow_other_orgs %>
<div class="clearfix"></div>
<%= f.hidden_field :other_org_id, value: other_org.present? ? other_org.id : '' %>
<%= f.hidden_field :other_org_name, value: other_org.present? ? other_org.name : '' %>
<a href="#" class="other-org-link"><%= _('My organisation isn\'t listed.') %></a>
<div class="clearfix"></div>
<%= f.text_field :other_organisation, autocomplete: "off", class: "form-control hide other-org",
placeholder: _('Please enter the name of your organisation'),
"aria-label": "other_organisation" %>
<% end %>
<% if f.object.errors[:org].present? %>
</div>
<% end %>