Reputation: 13012
So i made a Validation that will check gender if an accurate ID number is inputted, if the data is incorrect then an error will appear beneath the select within the form.
.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 *')
without the %br
i have the form return the error like this
Is there a less hacky way so that when the error is displayed that it renders it something like this. so that the errors don't overflow onto other form elements
%br
= participant.errors[:gender]
%br
Upvotes: 0
Views: 37
Reputation:
.field-error
= participant.errors[:gender]
Then use css to style the field-error class.
Upvotes: 1
Reputation: 5474
You should use CSS styles to control the errors layout/visual appearance instead of additional HTML tags.
Upvotes: 1