Search code examples
ruby-on-railsrubyspree

From where comes extra html for Spree login page?


This is _login.html.erb partial from Spree github page:

<%= form_for Spree::User.new, as: :spree_user, url: spree.create_new_session_path do |f| %>
  <fieldset id="password-credentials">
    <div class="form-group">
      <%= f.email_field :email, class: 'form-control', tabindex: 1, placeholder: Spree.t(:email) %>
    </div>
    <div class="form-group">
      <%= f.password_field :password, class: 'form-control', tabindex: 2, placeholder: Spree.t(:password) %>
    </div>
    <div class="checkbox">
      <label>
        <%= f.check_box :remember_me %>
        <%= f.label :remember_me, Spree.t(:remember_me) %>
      </label>
    </div>
    <div class="form-group">
      <%= f.submit Spree.t(:login), class: 'btn btn-lg btn-success btn-block', tabindex: 3 %>
    </div>
  </fieldset>
<% end %>

but in reality when go to that page that form is built-in in panel with heading "Login as Existing customer".

enter image description here

from where it comes?

enter image description here


Solution

  • That comes from a different template, located here: https://github.com/spree/spree_auth_devise/blob/master/app/views/spree/user_sessions/new.html.erb.

    If you search Spree's code for the sentence 'Login as Existing Customer', you'll see it's present in their locales with the key login_as_existing.

    A little more digging, and I found the key on line five of the template linked above (as well as a couple of other locations). You can replace this in the same way you have the login form, or adjust the locale if you'd prefer different terminology. And a final third option, you can use Spree's deface overrides.

    Tricky to track down these views sometimes, though search the main repo and any of the included extensions and you should be able to track anything down :)