2013-11-24 16 views
1

如何顯示來自modx寄存器片段的所有驗證錯誤?如何顯示來自modx寄存器片段的所有驗證錯誤?

現在如果我想表明我的形式,所有可能的錯誤,我必須做這樣的事情:

[[+error.message:notempty=`[[+error.message]]<br>`]] 
[[+error.username:notempty=`[[+error.username]]<br>`]] 
[[+error.password:notempty=`[[+error.password]]<br>`]] 
[[+error.password_confirm:notempty=`[[+error.password_confirm]]<br>`]] 
[[+error.email:notempty=`[[+error.email]]<br>`]] 
[[+error.salutation:notempty=`[[+error.salutation]]<br>`]] 
[[+error.firstname:notempty=`[[+error.firstname]]<br>`]] 
[[+error.lastname:notempty=`[[+error.lastname]]<br>`]] 
[[+error.institution:notempty=`[[+error.institution]]<br>`]] 
[[+error.excountry:notempty=`[[+error.excountry]]<br>`]] 
[[+error.province:notempty=`[[+error.province]]<br>`]] 
[[+error.provinceother:notempty=`[[+error.provinceother]]<br>`]] 
[[+error.excity:notempty=`[[+error.excity]]<br>`]] 
[[+error.oncologist-database:notempty=`[[+error.oncologist-database]]<br>`]] 

有誰知道,如果有,只是轉儲所有錯誤的佔位符?

+1

你的問題實際上幫助我解決了同樣的問題。我不知道爲什麼錯誤消息並不是全部輸入到error.message佔位符中,但是單獨的錯誤消息對我來說非常合適。謝謝! – aecend

回答

0

你對片段中錯誤的產生方式一無所知。

對此有兩種認可。您可以將整個錯誤消息合併到代碼片段中。這樣你可以簡單地將它們連接在一起。它只需要一個佔位符。

或者您可以在每次顯示塊時提供所有錯誤消息。改變是,當沒有錯誤消息時,佔位符只是空的(這樣,你不需要用notempty進行測試)。您也可以將<br />作爲錯誤字符串本身的一部分。這樣你根本不需要查詢,你可以把每個錯誤信息列出來。它會在塊中「更乾淨」,但我更喜歡第一種解決方案。