移动输入框的简单表单错误消息
Simple form error messages moving input boxes
我在 "registration" 表单上使用 simple_form gem 格式化错误消息的方式有问题。
This is what my registration form looks like when handling errors.
我希望错误消息显示在输入框下方,并且我不希望在提交错误输入时更改输入框的对齐方式。输入和错误消息的结构如下所示:
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= f.error_notification input_html: { class: 'error' } %>
<div class="panel-body">
<%= f.input :email, required: true, autofocus: true, label: false, placeholder: 'Email', input_html: { class: 'input-lg' } %>
<%= f.input :user_name, required: true, label: false, placeholder: 'User Name', input_html: { class: 'input-lg' } %>
<%= f.input :password, required: true, label: false, placeholder: 'Password', input_html: { class: 'input-lg' } %>
<%= f.input :password_confirmation, required: true, label: false, placeholder: 'Confirm Password', input_html: { class: 'input-lg' } %>
我是否可以在 css 中进行调整,使错误消息显示在输入框下方的中央?我试过弄乱边距,但当我这样做时,输入框会改变对齐方式。
找到解决方案,非常简单。只需按如下方式编辑 CSS:
.error {
display: block;
text-align: center;
}
我在 "registration" 表单上使用 simple_form gem 格式化错误消息的方式有问题。 This is what my registration form looks like when handling errors.
我希望错误消息显示在输入框下方,并且我不希望在提交错误输入时更改输入框的对齐方式。输入和错误消息的结构如下所示:
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= f.error_notification input_html: { class: 'error' } %>
<div class="panel-body">
<%= f.input :email, required: true, autofocus: true, label: false, placeholder: 'Email', input_html: { class: 'input-lg' } %>
<%= f.input :user_name, required: true, label: false, placeholder: 'User Name', input_html: { class: 'input-lg' } %>
<%= f.input :password, required: true, label: false, placeholder: 'Password', input_html: { class: 'input-lg' } %>
<%= f.input :password_confirmation, required: true, label: false, placeholder: 'Confirm Password', input_html: { class: 'input-lg' } %>
我是否可以在 css 中进行调整,使错误消息显示在输入框下方的中央?我试过弄乱边距,但当我这样做时,输入框会改变对齐方式。
找到解决方案,非常简单。只需按如下方式编辑 CSS:
.error {
display: block;
text-align: center;
}