<% # Unclear why this url/method hack is needed %> <%= form_for @allowed_user, :url => @allowed_user.persisted? ? admin_allowed_user_path(@allowed_user.id) : admin_allowed_users_path, :method => @allowed_user.persisted? ? :put : :post, :html => {:class => 'form-horizontal'} do |f| %>
<%= f.label :external do %> <%= check_box_tag :external, '1', false, { :disabled => !@allowed_user.id.blank? } %>Managed externally (LDAP, Okta, etc.)? <% end %>
<%= f.label :kb_username, 'Name', :class => 'col-sm-2 control-label' %>
<%= f.text_field :kb_username, :class => 'form-control', :required => true, :disabled => @allowed_user.persisted?, :readonly => @allowed_user.persisted? %>
<%= f.label :password, 'Password', :class => 'col-sm-2 control-label' %>
<%= password_field_tag :password, nil, class:'form-control' %>
<%= f.label :description, 'Description', :class => 'col-sm-2 control-label' %>
<%= f.text_field :description, :class => 'form-control' %>
<%= label_tag :roles, 'Roles', :class => 'col-sm-2 control-label' %>
<%= text_field_tag :roles, @roles.join(','), :class => 'form-control' %>

Comma separated, e.g. customer_support,finance.

Create a new role <%= link_to 'here', new_role_definition_path %>.

<%= f.submit 'Save', :class => 'btn btn-default' %>
<% end %> <% if @allowed_user.persisted? %> <% end %> <%= javascript_tag do %> $(document).ready(function() { $('#external').change(function() { is_killbill_managed(); }); function is_killbill_managed() { var isKillbillManaged = isBlank($('#killbillManaged').val()) || $('#killbillManaged').val() == 'true'; if ($('#external').is(":checked") || !isKillbillManaged) { $('#password').attr('disabled', true); $('#roles').attr('disabled', true); $('.help-block').hide(); $('.managed-externally-notice').show(); } else { $('#password').attr('disabled', false); $('#roles').attr('disabled', false); $('.help-block').show(); $('.managed-externally-notice').hide(); } } is_killbill_managed(); }); <% end %>