<%= simple_form_for(@user, html: {class: 'form-horizontal'}) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :name, autofocus: true %>
    <%= f.input :email %>    
    <%= f.input :phone_number %>
    
    <% if can? :manage_user_institution, User %>
      <%= f.input :institution_name, collection: Institution.all.map(&:name), as: :select %>
    <% else %>
      <%= f.input :institution_name, collection: [current_user.institution], as: :select, include_blank: false %>
    <% end %>

    <% if can? :manage_user_roles, User %>
      <% if can? :assign_admin_user, User %>
        <%= f.association :roles, collection: Role.all.sort.map {|r| [r.name.titleize, r.id] }, as: :check_boxes %>
      <% else %>
        <%= f.association :roles, collection: Role.all.where('name is not "admin"').sort.map { |r| [r.name.titleize, r.id] }, as: :check_boxes %>
      <% end %>
    <% end %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Submit", {class: "btn btn-success"} %>
    <%= show_link @user, "Cancel" %>
  </div>
<% end %>
<%= simple_form_for(@user, html: {class: 'form-horizontal'}) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :name, autofocus: true %>
    <%= f.input :email %>    
    <%= f.input :phone_number %>
    
    <% if can? :manage_user_institution, User %>
      <%= f.input :institution_name, collection: Institution.all.sort.map(&:name), as: :select %>
    <% else %>
      <%= f.input :institution_name, collection: [current_user.institution], as: :select, include_blank: false %>
    <% end %>

    <% if can? :manage_user_roles, User %>
      <% if can? :assign_admin_user, User %>
        <%= f.association :roles, collection: Role.all.sort.map {|r| [r.name.titleize, r.id] }, as: :check_boxes %>
      <% else %>
        <%= f.association :roles, collection: Role.all.where('name is not "admin"').sort.map { |r| [r.name.titleize, r.id] }, as: :check_boxes %>
      <% end %>
    <% end %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Submit", {class: "btn btn-success"} %>
    <%= show_link @user, "Cancel" %>
  </div>
<% end %>
Improve sort on User form for institution
Improve sort on User form for institution
