tabletop-companion/app/views/users/_form.html.erb

53 lines
1.5 KiB
Plaintext

<%# locals: (user:, button_text:) -%>
<section class="inset">
<%= form_with model: user do |f| %>
<%= f.label :username %>
<%= f.text_field :username, required: true, disabled: user.persisted? %>
<%= display_form_errors(user, :username) %>
<%= f.label :first_name %>
<%= f.text_field :first_name %>
<%= display_form_errors(user, :first_name) %>
<%= f.label :last_name %>
<%= f.text_field :last_name %>
<%= display_form_errors(user, :last_name) %>
<%= f.label :email %>
<%= f.text_field :email, required: true, disabled: user.persisted? %>
<%= display_form_errors(user, :email) %>
<% if user.new_record? %>
<fieldset>
<legend><%= t(".password") %></legend>
<%= f.label :password %>
<%= f.password_field :password, required: user.new_record? %>
<%= display_form_errors(user, :password) %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, required: user.new_record? %>
<%= display_form_errors(user, :password_confirmation) %>
</fieldset>
<% end %>
<hr>
<% if user.persisted? %>
<%= f.label :delete_avatar %>
<%= f.check_box :delete_avatar %>
<%= f.label :avatar %>
<%= f.file_field :avatar %>
<%= display_form_errors(user, :avatar) %>
<%= f.label :profile %>
<%= f.rich_text_area :profile %>
<%= display_form_errors(user, :profile) %>
<% end %>
<%= f.submit button_text %>
<% end %>
</section>