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

56 lines
1.7 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) %>
<fieldset>
<legend><%= t(".password") %></legend>
<% if user.persisted? %>
<%= f.label :password_challenge, t(".current_password") %>
<%= f.password_field :password_challenge, required: user.new_record? %>
<%= display_form_errors(user, :password_challenge) %>
<p><%= t(".password_hint") %></p>
<% end %>
<%= 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>
<hr>
<% if user.persisted? %>
<%= 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>