Note that there are some explanatory texts on larger screens.

plurals
  1. POfieldWithErrors not wrapping every error field
    primarykey
    data
    text
    <p>Notice the following result when I submit blank :title and :description fields</p> <p><a href="http://www.freeimagehosting.net/uploads/c14b4a2d74.png" rel="nofollow noreferrer">Error div tags only wraps the title text field and not the description text area. http://www.freeimagehosting.net/uploads/c14b4a2d74.png</a></p> <p>The validations are in the controller:</p> <pre><code>class Question &lt; ActiveRecord::Base validates_presence_of :title validates_presence_of :description </code></pre> <p>And, the form is generated with those names:</p> <pre><code>-form_for(@question) do |f| = f.error_messages = f.label :title = f.text_field :title, :size =&gt; 50, :onchange =&gt; remote_function(:url =&gt; {:action =&gt; :display_tag_suggestions}, :with =&gt; 'Form.Element.serialize(this)') #suggestions = f.label :description = f.text_area :description ... </code></pre> <p>But, for some reason, only :title gets wrapped in the error div tags:</p> <pre><code>&lt;form action="/questions" class="new_question" id="new_question" method="post"&gt; &lt;div style="margin:0;padding:0"&gt;&lt;input name="authenticity_token" type="hidden" value="6HQaiu1D0gBQcKw2pLeZP6Jvn0FSClPD5Sk9HwegzPg=" /&gt;&lt;/div&gt; &lt;div class="errorExplanation" id="errorExplanation"&gt; &lt;h2&gt;2 errors prohibited this question from being saved&lt;/h2&gt; &lt;p&gt;There were problems with the following fields:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Title can't be blank&lt;/li&gt; &lt;li&gt;Description can't be blank&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;label for="question_title"&gt;Title&lt;/label&gt; &lt;div class="fieldWithErrors"&gt;&lt;input id="question_title" name="question[title]" onchange="new Ajax.Request('/questions/display_tag_suggestions', {asynchronous:true, evalScripts:true, parameters:Form.Element.serialize(this) + '&amp;amp;authenticity_token=' + encodeURIComponent('6HQaiu1D0gBQcKw2pLeZP6Jvn0FSClPD5Sk9HwegzPg=')})" size="50" type="text" value="" /&gt;&lt;/div&gt; &lt;label for="question_description"&gt;Description&lt;/label&gt; &lt;textarea cols="40" id="question_description" name="question[description]" rows="20"&gt;&lt;/textarea&gt; ... </code></pre> <p>I don't think that behavior is expected. The problem most people have is that it's wrapping things with divs, which won't display properly. My problem is that fields aren't being wrapped with divs to begin with!</p> <p>I haven't made any (conscious) changes to how errors are handled, so I'm not sure why it's not working properly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload