OK, I find it. html_tag includes the labels.
On Mar 14, 2012, at 6:32 PM, Zhi-Qiang Lei wrote:

I'm developing with ruby 1.9.2 and rails 3.2.2. Currently I want to customize the error message html, to place the error message below a text area. But what it behaves is two message box around the text area. Do you know where the problem is? Thanks.

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
errors = instance.error_message
errors_list = "<ul>" + errors.map { |e| "<li>#{e}</li>" }.join + "</ul>"
%(#{html_tag}<section class="validation-error"><h2>Errors</h2>#{errors_list}</section>).html_safe
end

<section class='field' id='content'>
<label for="script_content">Content</label>
<section class="validation-error"><h2>Errors</h2><ul><li>can't be blank</li></ul></section>
<br>
<textarea cols="40" id="script_content" name="script[content]" rows="20"></textarea>
<section class="validation-error"><h2>Errors</h2><ul><li>can't be blank</li></ul></section>
</section>

Best regards,
Zhi-Qiang Lei
zhiqiang.lei@gmail.com

Best regards,
Zhi-Qiang Lei
zhiqiang.lei@gmail.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMar 14, '12 at 10:33a
activeMar 14, '12 at 2:48p
posts2
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Zhi-Qiang Lei: 2 posts

People

Translate

site design / logo © 2022 Grokbase