我有一个简单的联系表格。当我提交表格错误消息时不显示。请帮助我
class Users_Form_ContactForm extends Zend_Form{
public function init(){
$this->setName('contact');
$user_name = new Zend_Form_Element_Text('name');
$user_name->setLabel($this->getView()->translate('Ismingiz:'));
$user_name->setRequired(true)
->addValidator('alnum')
->addFilter('StripTags')
->addFilter('StringTrim')
->setAttrib('class', 'input margin_top_10');
$email_validate = new Zend_Validate_EmailAddress();
$email_validate->setMessages(array(
Zend_Validate_EmailAddress::INVALID => "1. Invalid type given, value should be a string",
Zend_Validate_EmailAddress::INVALID_FORMAT => "2. '%value%' is no valid email address in the basic format local-part@hostname",
Zend_Validate_EmailAddress::INVALID_HOSTNAME => "3. '%hostname%' is no valid hostname for email address '%value%'",
Zend_Validate_EmailAddress::INVALID_MX_RECORD => "4. '%hostname%' does not appear to have a valid MX record for the email address '%value%'",
Zend_Validate_EmailAddress::INVALID_SEGMENT => "5. '%hostname%' is not in a routable network segment. The email address '%value%' should not be resolved from public network.",
Zend_Validate_EmailAddress::DOT_ATOM => "6. '%localPart%' can not be matched against dot-atom format",
Zend_Validate_EmailAddress::QUOTED_STRING => "7. '%localPart%' can not be matched against quoted-string format",
Zend_Validate_EmailAddress::INVALID_LOCAL_PART => "8. '%localPart%' is no valid local part for email address '%value%'",
Zend_Validate_EmailAddress::LENGTH_EXCEEDED => "9. '%value%' exceeds the allowed length",
));
$email = new Zend_Form_Element_Text("email");
$email->setLabel($this->getView()->translate("Email manzilingiz:"))
->setRequired(true)
->addValidator($email_validate)
->addFilter('StringTrim')
->setAttrib('class', 'input margin_top_10')
->addFilter('StringToLower');
$captcha = new Zend_Form_Element_Captcha('captcha', array(
'captcha' => array(
'captcha' => 'MyImage',
'label' => $this->getView()->translate('Rasmdagi belgilarni kiriting'),
'required' => true,
'wordLen' => 5,
'width' => 150,
'height' => 40,
'timeout' => 300,
'fontSize' => 20,
'gcFreq' => 5,
'dotNoiseLevel' => 0,
'lineNoiseLevel' => 0,
'background' => 0,
'font' => 'files/captcha/fonts/1.ttf',
'imgDir' => 'files/captcha/image',
'imgUrl' => '/files/captcha/image',
)
));
$captcha->setIgnore(true);
$captcha->setAttrib('class', 'input margin_top_10');
$text = new Zend_Form_Element_Textarea("text");
$text->setRequired(true)
->addFilter('StringTrim')
->setAttrib('class', 'input margin_top_10')
->addFilter('StringToLower')
->setLabel($this->getView()->translate("Xat matni:"))
->setAttrib('maxlength','200')
->setAttrib('style','height:100px;width:360px;');
$button = new Zend_Form_Element_Submit('users_button');
$button->setLabel($this->getView()->translate('Kiritish'))
->setAttrib('class', 'input margin_top_10');
$this->addElements(array($user_name, $email, $text,$captcha, $button));
$this->setMethod('post');
$lang = $_SESSION['Poputchik']['slang'];
$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/' . $lang . '/default/category/contact');
$language = $_SESSION['Poputchik']['language'];
$translator = new Zend_Translate('array', APPLICATION_PATH.'/languages/errors/'.$language.'.php');
$this->setTranslator($translator);
}
}