Permalink
Browse files

Adding Twitter Bootstrap style to Devise forms

  • Loading branch information...
1 parent 0ff207e commit 0071161ddc4ef4c8cb4186ffa9b1be1a977784fe @akitaonrails committed Jul 14, 2012
View
10 app/views/devise/confirmations/new.html.erb
@@ -1,12 +1,14 @@
<h1><%= t(".title") %></h1>
-<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
+<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), html: { method: :post, class: "well" }) do |f| %>
<%= devise_error_messages! %>
- <div><%= f.label :email %><br />
- <%= f.email_field :email %></div>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
- <div><%= f.submit t(".submit") %></div>
+ <div class="control">
+ <%= f.submit t(".submit"), class: "btn" %>
+ </div>
<% end %>
<%= render "devise/shared/links" %>
View
14 app/views/devise/passwords/edit.html.erb
@@ -1,16 +1,18 @@
<h2><%= t(".title") %></h2>
-<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: { method: :put, class: "well" }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
- <div><%= f.label :password, "New password" %><br />
- <%= f.password_field :password %></div>
+ <%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
- <div><%= f.label :password_confirmation, "Confirm new password" %><br />
- <%= f.password_field :password_confirmation %></div>
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
- <div><%= f.submit t(".submit") %></div>
+ <div class="controls">
+ <%= f.submit t(".submit"), class: "btn" %>
+ </div>
<% end %>
<%= render "devise/shared/links" %>
View
10 app/views/devise/passwords/new.html.erb
@@ -1,12 +1,14 @@
<h2><%= t(".title") %></h2>
-<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: { method: :post, class: "well" }) do |f| %>
<%= devise_error_messages! %>
- <div><%= f.label :email %><br />
- <%= f.email_field :email %></div>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
- <div><%= f.submit t(".submit") %></div>
+ <div class="controls">
+ <%= f.submit t(".submit"), class: "btn" %>
+ </div>
<% end %>
<%= render "devise/shared/links" %>
View
24 app/views/devise/registrations/edit.html.erb
@@ -1,25 +1,27 @@
<h2><%= t ".title", resource: resource_name.to_s.humanize %></h2>
-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { method: :put, class: "well" }) do |f| %>
<%= devise_error_messages! %>
- <div><%= f.label :email %><br />
- <%= f.email_field :email %></div>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
- <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
- <%= f.password_field :password, :autocomplete => "off" %></div>
+ <%= f.label :password %> <i>(leave blank if you don't want to change it)</i>
+ <%= f.password_field :password, :autocomplete => "off" %>
- <div><%= f.label :password_confirmation %><br />
- <%= f.password_field :password_confirmation %></div>
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
- <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
- <%= f.password_field :current_password %></div>
+ <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i>
+ <%= f.password_field :current_password %>
- <div><%= f.submit t(".update") %></div>
+ <div class="controls">
+ <%= f.submit t(".update"), class: "btn" %>
+ </div>
<% end %>
<h3><%= t(".cancel.title") %></h3>
<p><%= t(".cancel.message") %> <%= link_to t(".cancel.action"), registration_path(resource_name), :data => { :confirm => t(".cancel.confirm") }, :method => :delete %>.</p>
-<%= link_to "Back", :back %>
+<%= link_to t(".back"), :back %>
View
18 app/views/devise/registrations/new.html.erb
@@ -1,18 +1,20 @@
<h2><%= t(".title") %></h2>
-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { class: "well" }) do |f| %>
<%= devise_error_messages! %>
- <div><%= f.label :email %><br />
- <%= f.email_field :email %></div>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
- <div><%= f.label :password %><br />
- <%= f.password_field :password %></div>
+ <%= f.label :password %>
+ <%= f.password_field :password %>
- <div><%= f.label :password_confirmation %><br />
- <%= f.password_field :password_confirmation %></div>
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
- <div><%= f.submit t(".submit") %></div>
+ <div class="controls">
+ <%= f.submit t(".submit"), class: "btn" %>
+ </div>
<% end %>
<%= render "devise/shared/links" %>
View
18 app/views/devise/sessions/new.html.erb
@@ -1,17 +1,21 @@
<h2><%= t(".title") %></h2>
-<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
- <div><%= f.label :email %><br />
- <%= f.email_field :email %></div>
+<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: { class: "well" }) do |f| %>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
- <div><%= f.label :password %><br />
- <%= f.password_field :password %></div>
+ <%= f.label :password %>
+ <%= f.password_field :password %>
<% if devise_mapping.rememberable? -%>
- <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
+ <%= f.label :remember_me, class: "checkbox" do %>
+ <%= f.check_box :remember_me %> <%= User.human_attribute_name(:remember_me) %>
+ <% end %>
<% end -%>
- <div><%= f.submit t(".submit") %></div>
+ <div class="controls">
+ <%= f.submit t(".submit"), class: "btn" %>
+ </div>
<% end %>
<%= render "devise/shared/links" %>
View
42 app/views/devise/shared/_links.erb
@@ -1,25 +1,29 @@
-<%- if controller_name != 'sessions' %>
- <%= link_to t("devise.sessions.new.title"), new_session_path(resource_name) %><br />
-<% end -%>
+<div class="well">
+ <ul class="unstyled">
+ <%- if controller_name != 'sessions' %>
+ <li><%= link_to t("devise.sessions.new.title"), new_session_path(resource_name) %></li>
+ <% end -%>
-<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
- <%= link_to t("devise.registrations.new.title"), new_registration_path(resource_name) %><br />
-<% end -%>
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <li><%= link_to t("devise.registrations.new.title"), new_registration_path(resource_name) %></li>
+ <% end -%>
-<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
- <%= link_to t("devise.passwords.new.title"), new_password_path(resource_name) %><br />
-<% end -%>
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <li><%= link_to t("devise.passwords.new.title"), new_password_path(resource_name) %></li>
+ <% end -%>
-<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
- <%= link_to t("devise.confirmations.link"), new_confirmation_path(resource_name) %><br />
-<% end -%>
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <li><%= link_to t("devise.confirmations.link"), new_confirmation_path(resource_name) %></li>
+ <% end -%>
-<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
- <%= link_to t("devise.unlocks.link"), new_unlock_path(resource_name) %><br />
-<% end -%>
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <li><%= link_to t("devise.unlocks.link"), new_unlock_path(resource_name) %></li>
+ <% end -%>
-<%- if devise_mapping.omniauthable? %>
- <%- resource_class.omniauth_providers.each do |provider| %>
- <%= link_to t("devise.sessions.link", provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) %><br />
+ <%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <li><%= link_to t("devise.sessions.link", provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) %></li>
+ <% end -%>
<% end -%>
-<% end -%>
+ </ul>
+</div>
View
10 app/views/devise/unlocks/new.html.erb
@@ -1,12 +1,14 @@
<h1><%= t(".title") %></h1>
-<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
+<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), html: { method: :post, class: "well" }) do |f| %>
<%= devise_error_messages! %>
- <div><%= f.label :email %><br />
- <%= f.email_field :email %></div>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
- <div><%= f.submit t(".submit") %></div>
+ <div class="controls">
+ <%= f.submit t(".submit"), class: "btn" %>
+ </div>
<% end %>
<%= render "devise/shared/links" %>

0 comments on commit 0071161

Please sign in to comment.