<%= tag.section data: {
      controller: "settings--email--password",
      "settings--email--password-validation-failed-value": @validation_errors.present?
    } do %>
  <h3>E-Mail Password</h3>
  <%= form_for(@user, url: reset_email_password_settings_path, method: "post") do |f| %>
    <%= hidden_field_tag :section, "email" %>
    <p class="mb-8">
      Use the following button to generate a new email password:
    </p>
    <p class="hidden initial-visible">
      <button type="button" id="edit-email" class="btn-md btn-gray"
              data-settings--email--password-target="resetPasswordButton"
              data-action="settings--email--password#showPasswordReset">
        Reset email password
      </button>
    </p>
    <div class="initial-hidden">
      <p class="mt-4 mb-2">
        <%= f.label :current_password, 'Current account password', class: 'font-bold' %>
      </p>
      <p class="sm:w-3/5">
        <%= f.password_field :current_password, class: "w-full", required: true,
              data: { 'settings--email--password-target': "currentPasswordField" } %>
      </p>
      <% if @validation_errors.present? && @validation_errors[:current_password].present? %>
        <p class="error-msg"><%= @validation_errors[:current_password].first %></p>
      <% end %>
      <p class="mt-6">
        <%= f.submit "Create new email password", class: "btn-md btn-blue w-full md:w-auto" %>
      </p>
    </div>
  <% end %>
<% end %>
