Has anyone encountered this rails/css forms error issue? ...the rails
generated <div class="fieldWithErrors"> that surrounds the input field
with the error causes the field to flow outside its container and
messes up the forms spacing/alignment.
For example, if HTML-wise I organize my form like this:
<p><label for="login">Username</label><input id="login" name="login"
type="text" /></p>
<p><label for="password">Password</label><input id="password"
name="password" type="password" /></p>
Where the css looks like this:
form p {
clear: both;
}
form label {
float: left;
width: 11em;
}
form input {
float: left;
width: 200px;
}
Everything works fine until the user fails a validation. I tried a
bunch of things to bring the div back into the flow, but nothing
worked. Then I tried to position it correctly using floats and margin
fixes on the rails generated div and that worked fine everywhere but
IE (see attached).
I can't figure out where the extra spacing is coming from and I'm going nuts?
Chris
What I did is change the rails default from div to span...
# File actionpack/lib/action_view/helpers/active_record_helper.rb, line 6:
------------------------------------------------------------------------------
module ActionView
class Base
@@field_error_proc = Proc.new{ |html_tag, instance| "<span
class=\"fieldWithErrors\">#{html_tag}</span>" }
cattr_accessor :field_error_proc
end
------------------------------------------------------------------------------
...and then styled with default selectors.
Chris
display: inline;
http://webdesign.about.com/od/htmltags/a/aa011000a.htm
Chris