john seymour
john seymour

Reputation: 213

Devise form submit button not working

Not sure if is this connected in any way but earlier today I updated the devise gem to v 4.4.3

On my sign up form I have the devise form slightly altered:

<div class="input">
     <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
        <%= devise_error_messages! %>
      <div class="form-label font-medium ">
        Email address
      </div>
      <div class="form-input">
        <%= f.email_field :email, autofocus: true, autocomplete: "email", class: "form-control" %> <br />
      </div>

      <div class="form-label font-medium ">
        Username<br />
      </div>
      <div class="form-input">
        <%= f.text_field :username, autocomplete: "off", class: "form-control" %>  <br>
      </div>

      <div class="form-label font-medium ">
        Password<br />
      </div>
      <div class="form-input">
        <%= f.password_field :password, autocomplete: "off", class: "form-control" %><br>
      </div>

      <div class="form-label font-medium ">
        Password confirmation  <br />
      </div>
      <div class="form-input">
        <%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control" %> <br />
      </div>
    </div>

<div class="button-inputs">
  <div class="actions flerowspb">
    <span>
      <%= f.submit "Sign up", class: "btn btn-primary", style: "width:408px;"%>
    </span>
    <% end %>
    <span>
      <%= button_to "Sign in", new_user_session_path, method: :get, class: "btn btn-info", style: "width:186px;"%>
    </span>
  </div>
</div>

When I click on the sign-up link

<%= link_to "Sign up", new_user_registration_path %>

it takes me the URL:

http://localhost:3000/users/sign_up

Which is correct, But then when I click submit on the form without filling any fields in, nothing happens at all, apart from it goes into focus scss state.

Before click:

enter image description here

After click:

enter image description here

If I then refresh the page then the submit button will work and the page refreshes with the error flash messages etc as expected BUT now the URL is:

http://localhost:3000/users and then press refresh again... it takes me to Users index page.

I'm a bit baffled by it, Any ideas as to what is happening with the button will be appreciated.

Thanks

Upvotes: 1

Views: 829

Answers (1)

Ganesh
Ganesh

Reputation: 2004

You have not closed </div> correctly, before div class="button-inputs">, So please modify view as follows,

<div class="input">
  <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
    <%= devise_error_messages! %>
    <div class="form-label font-medium ">
      Email address
    </div>
    <div class="form-input">
      <%= f.email_field :email, autofocus: true, autocomplete: "email", class: "form-control" %> <br />
    </div>

    <div class="form-label font-medium ">
      Username<br />
    </div>
    <div class="form-input">
      <%= f.text_field :username, autocomplete: "off", class: "form-control" %>  <br>
    </div>

    <div class="form-label font-medium ">
      Password<br />
    </div>
    <div class="form-input">
      <%= f.password_field :password, autocomplete: "off", class: "form-control" %><br>
    </div>

    <div class="form-label font-medium ">
      Password confirmation  <br />
    </div>
    <div class="form-input">
      <%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control" %> <br />
    </div>

    <div class="button-inputs">
      <div class="actions flerowspb">
        <span>
          <%= f.submit "Sign up", class: "btn btn-primary", style: "width:408px;"%>
        </span>
        <span>
          <%= button_to "Sign in", new_user_session_path, method: :get, class: "btn btn-info", style: "width:186px;"%>
        </span>
      </div>
    </div>
  <% end %>
</div>

Hope this will work for you.

Upvotes: 2

Related Questions