Devise /shared/_links.html.erb 的按钮组
Button Groups for Devise /shared/_links.html.erb
我使用 bootstrap 设计了表格。
我喜欢把 shared/_links 上的按钮组合在一起。html.erb。
<div class="button-group btn-group-xs" role="group">
<%- if controller_name != 'sessions' %>
<%= button_to "Log in", new_session_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= button_to "Sign up", new_registration_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= button_to "Forgot your password?", new_password_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= button_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= button_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= button_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<% end -%>
</div>
结果我明白了。
我怀疑这是因为每个按钮都有一个表单标签。有没有办法只使用 bootstrap 来解决这个问题?
<div class="col-md-12 control">
<div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
<div class="button-group btn-group-xs" role="group">
<form class="button_to" method="get" action="/users/sign_up"><input class="btn btn-default" type="submit" value="Sign up" /></form>
<form class="button_to" method="get" action="/users/password/new"><input class="btn btn-default" type="submit" value="Forgot your password?" /></form>
<form class="button_to" method="get" action="/users/confirmation/new"><input class="btn btn-default" type="submit" value="Didn't receive confirmation instructions?" /></form>
</div>
</div>
</div>
恢复为 link_to
已移除
button_to
method="get"
返回
link_to
Rails 在 button_to 字段周围添加表单标签导致对齐问题,通过将 btn class 添加到 link_to 它确实显示为按钮。
我使用 bootstrap 设计了表格。
我喜欢把 shared/_links 上的按钮组合在一起。html.erb。
<div class="button-group btn-group-xs" role="group">
<%- if controller_name != 'sessions' %>
<%= button_to "Log in", new_session_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= button_to "Sign up", new_registration_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= button_to "Forgot your password?", new_password_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= button_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= button_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= button_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), :class => 'btn btn-default', :type => 'button', :method => :get %>
<% end -%>
<% end -%>
</div>
结果我明白了。
我怀疑这是因为每个按钮都有一个表单标签。有没有办法只使用 bootstrap 来解决这个问题?
<div class="col-md-12 control">
<div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
<div class="button-group btn-group-xs" role="group">
<form class="button_to" method="get" action="/users/sign_up"><input class="btn btn-default" type="submit" value="Sign up" /></form>
<form class="button_to" method="get" action="/users/password/new"><input class="btn btn-default" type="submit" value="Forgot your password?" /></form>
<form class="button_to" method="get" action="/users/confirmation/new"><input class="btn btn-default" type="submit" value="Didn't receive confirmation instructions?" /></form>
</div>
</div>
</div>
恢复为 link_to
已移除
button_to
method="get"
返回
link_to
Rails 在 button_to 字段周围添加表单标签导致对齐问题,通过将 btn class 添加到 link_to 它确实显示为按钮。