Displaying validates_acceptance_of Errors In A Check Box

Hello,

I am having trouble displaying a check box which must be checked but
hasn’t been. I would like it to be highlighted as in a scaffolded
view but the hidden check box field which is generated by the
check_box helper is also highlighted, and the text next to it loses
its styling.

My code follows. Should I get cleverer with the CSS or write my own
check_box helper which wouldn’t wrap both the visible and the hidden
check boxes in

tags – or something
else altogether?

In my customer model I have:

validates_acceptance_of :terms

In my view I have:

<% form_for :customer, @customer, :url => { :action => :store } do |
c| %>

<%= c.check_box :terms %> I have read and agree to the Software Licence Agreement.

<%= submit_tag %> <% end %>

When the user submits the form without ticking the box, the view
renders again with erroneous fields highlighted as in a scaffolded view.

The HTML generated for the check box is:

I have read and agree to the Software Licence Agreement.

The CSS is:

.fieldWithErrors {
border: 1px solid red;
padding: 2px;
display: inline;
}

And the result unfortunately is that both the visible and invisible
check boxes are given a border and the text (“I have read…”) loses
the styling for

tags.

Thanks in advance,

Andy S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs