2010-06-05 3 views
1

주의 다음과 같은 결과를 포장하지 : 제목과 : 설명 필드 유효성 검증은 컨트롤러에fieldWithErrors 모든 오류 필드를

Error div tags only wraps the title text field and not the description text area. http://www.freeimagehosting.net/uploads/c14b4a2d74.png

:

class Question < ActiveRecord::Base 
    validates_presence_of :title 
    validates_presence_of :description 

그리고 양식 그 이름으로 생성됩니다 :

-form_for(@question) do |f| 
    = f.error_messages 
    = f.label :title 
    = f.text_field :title, :size => 50, :onchange => remote_function(:url => {:action => :display_tag_suggestions}, :with => 'Form.Element.serialize(this)') 
    #suggestions 
    = f.label :description 
    = f.text_area :description 
    ... 

그러나, 어떤 이유로 든 : title 만 오류 div 태그에 래핑됩니다.

<form action="/questions" class="new_question" id="new_question" method="post"> 
    <div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="6HQaiu1D0gBQcKw2pLeZP6Jvn0FSClPD5Sk9HwegzPg=" /></div> 
    <div class="errorExplanation" id="errorExplanation"> 
    <h2>2 errors prohibited this question from being saved</h2> 
    <p>There were problems with the following fields:</p> 
    <ul> 
     <li>Title can't be blank</li> 
     <li>Description can't be blank</li> 
    </ul> 
    </div> 
    <label for="question_title">Title</label> 
    <div class="fieldWithErrors"><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;authenticity_token=' + encodeURIComponent('6HQaiu1D0gBQcKw2pLeZP6Jvn0FSClPD5Sk9HwegzPg=')})" size="50" type="text" value="" /></div> 
    <label for="question_description">Description</label> 
    <textarea cols="40" id="question_description" name="question[description]" rows="20"></textarea> 
    ... 

동작이 예상되지 않습니다. 대부분의 사람들이 겪고있는 문제는 제대로 표시되지 않는 div로 배치한다는 것입니다. 내 문제는 필드 div 함께 시작되는 래핑되지 않는 것입니다!

오류 처리 방법을 (의식적으로) 변경하지 않았으므로 왜 제대로 작동하지 않는지 확신 할 수 없습니다.

+0

다른 모든 스타일 시트 뒤에 scaffold.css를 추가하십시오. – Salil

+0

저는 하나의 스타일 시트 만 사용하고 있으며 이미 scaffold.css의 내용을 추가하려고했습니다. 그러나 그것은 문제를 해결하지 못합니다. div가 설명 HTML 태그를 래핑하지 않습니다. – user5243421

답변

1

사용중인 Haml의 버전은 무엇입니까? 구형 버전 중 일부는 오류 랩핑과의 호환성 문제가있었습니다.

+0

Haml v2.2.23을 사용하고 있습니다. – user5243421

+0

현재 상태가 오래되었습니다. 3.0.9로 업그레이드하십시오. –

관련 문제