Re: CSS issue with div fieldWithErrors

Marnen Laibow-Koser
Thu, 01 Oct 2009 12:48:10 -0000

Fernando Perez wrote:
> Hi,
>
> What''s the correct way of writing a form?
>
> I do the following:
>
> <%= form_for ... %>
>
>   <%= f.label :whatever %>
>   <%= f.text_field :whatever %>
>
> <%- end -%>
>
> Then I do some CSS to have all the labels aligned, and all the input
> fields aligned. The problem happens when a field is not valid, Rails
> wraps it in this stupid div with class fieldWithErrors (and what the
> hell is that camelCaseCrap?), so it blows my design out.

If that''s ruining your design, then your CSS has problems.  It should
be
easy to define the CSS for fieldWithErrors so it doesn''t cause layout
issues.  (And it''s not stupid -- it''s a way of clearly showing
the user
where the errors are.)

For myself, I don''t have this problem because I lay out my forms with
table elements.  (Stop screaming. :)  They have the semantics of tables,
so this is justified.)

>
> Is there somewhere some easy CSS to circumvent that trouble? Nothing
> fancy, just a simple and clean form.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org