Forum: Ruby on Rails about rails error_messages

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
36b07c5c8b1e802259386e29dc705cd3?d=identicon&s=25 Difei Zhao (difei)
on 2009-03-04 17:00
Hi all,

  I have a web form:

<% form_for @comment do |f| %>
        <%= f.error_messages %>
  <p>
        <%= f.label :author %>
  <%= f.text_field :author, :size => 20 %>  %>
  </p>
  <p>
        <%= f.label :email %>
  <%= f.text_field :email, :size => 20 %>
  </p>
<% end %>

When the validation fails, the labels will be wrapped into <div>, so
labels and fields are in different lines, that is not what I want. If
you have the agile web development book, please turn to p.151 (the
source code is in p.146 and [1]), how did the author archived that?
Thanks.

Difei

1.
http://media.pragprog.com/titles/rails2/code/depot...
Bbbc7c2470ee942c9fd13abebb709b4f?d=identicon&s=25 Brent Miller (macstruan)
on 2009-03-04 20:57
There's lots of good info about how to customize the error message
output here:

http://apidock.com/rails/ActionView/Helpers/Active...

Difei Zhao wrote:
> Hi all,
>
>   I have a web form:
>
> <% form_for @comment do |f| %>
>         <%= f.error_messages %>
>   <p>
>         <%= f.label :author %>
>   <%= f.text_field :author, :size => 20 %>  %>
>   </p>
>   <p>
>         <%= f.label :email %>
>   <%= f.text_field :email, :size => 20 %>
>   </p>
> <% end %>
>
> When the validation fails, the labels will be wrapped into <div>, so
> labels and fields are in different lines, that is not what I want. If
> you have the agile web development book, please turn to p.151 (the
> source code is in p.146 and [1]), how did the author archived that?
> Thanks.
>
> Difei
>
> 1.
> http://media.pragprog.com/titles/rails2/code/depot...
This topic is locked and can not be replied to.