所以我做了一个验证,如果输入了准确的 ID 号,它将检查性别,如果数据不正确,那么表单中的选择下方会出现错误。
.col
%h4 Participant
= f.field(:full_name, :label => "Full name *")
= f.field(:id_number)
= f.field(:gender, :field_type => :select, :choices => GENDER_SELECT, :label => 'Gender *')
%br #note i added this as the 'hacky' fix
= f.field(:race, :field_type => :select, :choices => RACE_SELECT, :label => 'Race *')
没有%br
我有表单返回这样的错误
是否有一种不那么老套的方法,以便在显示错误时将其呈现为这样。这样错误就不会溢出到其他表单元素上
%br
= participant.errors[:gender]
%br