Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6039277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:20:42+00:00 2026-05-23T06:20:42+00:00

I have validator error translator connected with my Form class My_Lib_Forms_Form extends Zend_Form {

  • 0

I have validator error translator connected with my Form

  class My_Lib_Forms_Form extends Zend_Form {

    public function init()

   {
       parent::init();

       $translator = new Zend_Translate('array', APPLICATION_PATH . '/languages/errors.php');

       // Задаем объект переводчика для формы
       $this->setTranslator($translator);    
   }
}

Here is validator error translator code:

<?php
return $errors = array(
   Zend_Validate_Alnum::STRING_EMPTY => "Поле не может быть пустым",
   Zend_Validate_Date::INVALID_DATE => 'Значение не соответствует формату год-месяц-день',
   Zend_Validate_Date::INVALID => 'Неверная дата',
   Zend_Validate_Date::FALSEFORMAT => 'Значение не соответствует указанному формату',
   Zend_Validate_EmailAddress::INVALID_FORMAT => "asdasd",
   Zend_Validate_EmailAddress::INVALID_FORMAT => "Не верный формат адреса электронной почты. Введите почту в формате local-part@hostname",
   Zend_Validate_EmailAddress::INVALID_HOSTNAME => "'%hostname%' не верный домен для адреса электронной почты '%value%'",
   Zend_Validate_EmailAddress::INVALID_MX_RECORD => "'%hostname%' не имеет MX-записи об адресе электронной почты '%value%'",
   Zend_Validate_EmailAddress::DOT_ATOM => "'%localPart%' не соответствует формату dot-atom",
   Zend_Validate_EmailAddress::QUOTED_STRING => "'%localPart%' не соответствует формату quoted-string",
   Zend_Validate_EmailAddress::INVALID_LOCAL_PART => "'%localPart%' не верное имя для адреса электронной почты '%value%'",
   Zend_Validate_Int::NOT_INT => 'Значение не является целочисленным значением',
   Zend_Validate_NotEmpty::IS_EMPTY => 'Поле не может быть пустым',
   Zend_Validate_StringLength::TOO_SHORT => 'Длина введённого значения меньше чем %min% символов',
   Zend_Validate_StringLength::TOO_LONG => 'Длина введённого значения больше чем %max% символов',
   My_Lib_Validate_EqualInputs::NOT_EQUAL => 'Пароли не совпадают',
   My_Lib_Validate_Password::INVALID => 'Не верный формат пароля',
   My_Lib_Validate_Password::INVALID_LENGTH => 'Длина пароля должна быть от 7 до 30ти символов',
   Zend_Captcha_Word::BAD_CAPTCHA => 'Вы указали не верные символы',
   Zend_Captcha_Word::MISSING_VALUE => 'Поле не может быть пустым',
   'userAgreement' => 'Регистрируясь вы должны согласится с правилами',    
);

How to change validation error message for custom element?

I’m trying to do it next way:

$validatorNotEmpty = new Zend_Validate_NotEmpty();
$validatorNotEmpty->setMessages(array(
           Zend_Validate_NotEmpty::IS_EMPTY  => 'agreeRules'));
$userAgreement = new Zend_Form_Element_Checkbox('userAgreement', array(
           'required'    => true,
           'label'       => 'Регистрируясь, вы должны согласиться с правилами:',            
           'validators'  => array($validatorNotEmpty),
       ));

And this way too:

$validatorNotEmpty = new Zend_Validate_NotEmpty();
$validatorNotEmpty->setMessage(  'Регистрируясь вы должны согласится с правилами',
           Zend_Validate_NotEmpty::IS_EMPTY);
$userAgreement = new Zend_Form_Element_Checkbox('userAgreement', array(
           'required'    => true,
           'label'       => 'Регистрируясь, вы должны согласиться с правилами:',            
           'validators'  => array($validatorNotEmpty),
       ));

Anyway I get message from translator file, not my custom written message text.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:20:42+00:00Added an answer on May 23, 2026 at 6:20 am

    try

       $validatorNotEmpty->setMessages(array('agreeRules')); 
    

    it will overwrite all messages, but in IS_EMPTY case it actually is one message

    you could try the other approach, translate by value

    remove Zend_Validate_NotEmpty::IS_EMPTY => 'Поле не может быть пустым',

    $errors=array(
     //values
     'Value is required and cannot be empty' = > 'My translate',
     'agreeRules' => 'My rules'
    );
    

    then

    $validatorNotEmpty->setMessages(array(
           Zend_Validate_NotEmpty::IS_EMPTY  => 'agreeRules'));
    

    now your translation get the text and translates it,
    else the translator uses ‘notEmpty’ (Zend_Validate_NotEmpty::IS_EMPTY is a string) for translation key and ignores the text ‘agreeRules’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have model: [Validator(typeof(RegisterValidator))] public class RegisterModel { public string Name { get; set;
I have a form validator and when it fails, the error message doesn't show.
I have a multi-lingual page where I want to display form validation error in
I am new to QTP and I have a problem with error validation message.
I have the next element: $email = new Zend_Form_Element_Text('email'); $email->setAttribs(array('class' => 'input-text', 'id' =>
In my Asp.net MVC app, I have a custom validator class V and an
WHat's the best way/code in Login Form (Zend_Form) to display error message 'Login/password incorrect'?
I have a model where I want to translate the form validation error. So
In Rails 3.0 I have the standard 'new' form that creates a new record,
I have a custom validator and I am trying to output an error message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.