diff --git a/app/views/shared/_register_form.html.erb b/app/views/shared/_register_form.html.erb
index 1546594..e8eac9e 100644
--- a/app/views/shared/_register_form.html.erb
+++ b/app/views/shared/_register_form.html.erb
@@ -27,14 +27,11 @@
<%= f.hidden_field "user_identifiers[#{scheme}]", value: resource.user_identifiers.first.identifier%>
<% end %>
- <%= collection_select(:user, :org_id, Org.where("parent_id IS NULL").order("sort_name ASC, name ASC"), :id, :name, {include_blank: _('Organisation')}, { :class => 'typeahead org_sign_up' }) %>
+ <%= collection_select(:user, :org_id, Org.where("parent_id IS NULL").order("sort_name ASC, name ASC"), :id, :name, {include_blank: _('Organisation')}, { :class => 'typeahead org_sign_up', 'data-allow-clear': false }) %>
-
- <% other_organisations = Array.new %>
- <% Org.where("parent_id IS ? AND is_other = ?", nil, true).each do |org| %>
- <% other_organisations << org.id %>
- <% end %>
-
+
+ <% other_organisations = Org.where("parent_id IS ? AND is_other = ?", nil, true).pluck(:id) %>
+
<%= f.text_field :other_organisation, placeholder: ( _('Organisation name') + ' *'), :as => :string , :autocomplete => "off", :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Please enter the name of your organisation.') %>
diff --git a/lib/assets/javascripts/shared/register_form.js b/lib/assets/javascripts/shared/register_form.js
index 0a2be6c..ccf8642 100644
--- a/lib/assets/javascripts/shared/register_form.js
+++ b/lib/assets/javascripts/shared/register_form.js
@@ -12,12 +12,26 @@
allowClear: true
});
// TODO removing once the new create account functionality is in place
+ $('#user_org_id').on("change", function(e) {
+ e.preventDefault();
+ var selected_org = $(this).select2("val");
+ var other_orgs = $("#other-org-name").attr("data-orgs").split(",");
+ var index = $.inArray(selected_org, other_orgs);
+ if (index > -1) {
+ $("#other-org-name").show();
+ $("#user_other_organisation").focus();
+ }
+ else {
+ $("#other-org-name").hide();
+ $("#user_other_organisation").val("");
+ }
+ });
$("#other-org-link > a").click(function(e){
e.preventDefault();
- var other_org = $("#other-organisation-name").attr("data-orgs").split(",");
- $("#user_organisation_id").select2("val", other_org);
- $("#other-org-link").hide();
- $("#user_organisation_id").change();
+ var other_org = $("#other-org-name").attr("data-orgs").split(",");
+ $("#user_org_id").select2("val", other_org);
+ $("#user_org_id").change();
+ //$("#other-org-link").hide();
});
$("#user_email.text_field.reg-input").change(function(){
if (email_regex.test($(this).val())) {