0
remote_form_for 태그를 사용하여 제출하는 양식이 있습니다.RJS 레일을 사용한 양식 유효성 검사
보기
<% form_remote_tag(:url => { :action => 'create' }) do %>
a bunch of fields
<% end %>
컨트롤러
def create
if @greeting.can_save?
respond_to do |format|
format.html {redirect_to board_link(@board)}
format.js #close the iframe and reload the parent
end
else
respond_to do |format|
format.html {redirect_to :action => 'new'}
format.js #show the errors on the form
end
end
end
create.rjs
page << "parent.$.fancybox.close();"
양식이 올바른 정보와 함께 제출되는 모든 확인을 작동합니다. 하지만 잘못된 제출에 대한 오류 메시지를 표시해야합니다.
양식이 유효성 검사를 통과하지 못하면 어떻게 양식에 오류 메시지가 표시됩니까?
미리 감사드립니다.
덕분에 더글러스 나는 그에게 총을주고 그것이 어떻게되는지 보게됩니다. – chell