php - zend 2 - custom field name in validation message -


I would like to customize the input name to show in my view when there is an error in the verification of the form

  $ this-> Add ('Array' ('name' = & gt; 'generic_diskrio', // I have to give her name '' // 'custom_name' = & gt; 'Descrição', 'required' = & gt;; right, = & Gt; array (array ('name' = & gt; 'notEmpty', 'options' => array (' message '= & gt; array (' isEmpty '= & gt;' s campo node   

And when I call getMessage () as above <$> form $ ($ $ form-> isValid ()) {$ resultado = new result ( Results: FLAG_WARNING, $ form-> getMessages ()); $ resultado-> SetterOronoFro ($-- getServiceLocator ()); Return Result $ ->; GetJson ();}

They will come back

  array ('Descrição' = 'O cam po non pod ser vazio');  

Then I can give this array in my view and communicate with the correct message Can I show, how can this help in any of the joints?

I found the best approach , Create a new method that enhances the default form of the name from the label in the form.

  extends abstract genericForm form {public functions getMessagesTranslated ($ elementName = null) {$ mensagensOriginais = $ this- & gt; Get message ($ elementName); Foreign currency ($ mensagensOriginais as $ chave => $ mensagens) {$ label = translationUtil :: translation ($ this-> get ($ chave) -> getLabel ()); $ MensagensOriginais [$ label] = $ mensagensOriginais [$ chave]; Not set ($ mensagensOriginais [$ Chave]); } Return mensagensOriginais; }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Algorithm negotiation fail SSH in Jenkins -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -