Пример #1
0
	function setForm()
	{
		$form = new Zend_Form;
		$form->setMethod('post')->setAction('');
		
		$comment_name = new Zend_Form_Element_Text('comment_name');
		$comment_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập tên người gửi !'));
		$comment_name->setAttrib('class','n');
		$comment_name->setAttrib("onfocus","if (this.value == 'Nhập tên của bạn') {this.value = '';}");
		$comment_name->setAttrib("onblur","if (this.value == '') {this.value = 'Nhập tên của bạn';}");
		$comment_name->setValue("Nhập tên của bạn");
		
		$comment_email = new Zend_Form_Element_Text('comment_email');
		$comment_email->addValidator('EmailAddress',true,array('messages'=>'Địa chỉ email không hợp lệ'));
		$comment_email->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập địa chỉ email !'));
		$comment_email->setAttrib('class','e');
		$comment_email->setAttrib('onfocus',"if (this.value == 'Nhập địa chỉ email của bạn') {this.value = '';}");
		$comment_email->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập địa chỉ email của bạn';}");
		$comment_email->setValue('Nhập địa chỉ email của bạn');
		
		$comment_content = new Zend_Form_Element_Textarea('comment_content');
		$comment_content->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập nội dung bình luận!'));
		$comment_content->setAttrib('class','m');
		$comment_content->setAttrib('onfocus',"if (this.value == 'Nhập nội dung bình luận') {this.value = '';}");
		$comment_content->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập nội dung bình luận';}");
		$comment_content->setValue('Nhập nội dung bình luận');
		
		$comment_captcha = new Zend_Form_Element_Captcha('comment_captcha',array( 
                            'label' => 'Captcha_image', 
                             'captcha' => array( 
                                    'captcha' => 'Image', 
                                    'wordLen' => 6, 
                                    'timeout' => 300, 
                                    'font' => APPLICATION_PATH.'/templates/front/fonts/tiennd.TTF', 
                                    'imgDir' => APPLICATION_PATH.'/templates/front/captcha/', 
                                    'imgUrl' => $this->view->baseUrl().'/application/templates/front/captcha/', 
                                    'height' => 100, 
                                    'width' => 200, 
                                    'fontSize' => 50, 
                                ), 
        ));
        $comment_captcha->setAttrib('class','captcha_image1');
        $comment_captcha->setAttrib('onfocus',"if (this.value == 'Nhập hình ảnh xác nhận') {this.value = '';}");
		$comment_captcha->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập hình ảnh xác nhận';}");
        $comment_captcha->setValue('Nhập hình ảnh xác nhận');
		
		$comment_name->removeDecorator('HtmlTag')->removeDecorator('Label');
		$comment_email->removeDecorator('HtmlTag')->removeDecorator('Label');
		$comment_content->removeDecorator('HtmlTag')->removeDecorator('Label');
		$comment_captcha->removeDecorator('HtmlTag')->removeDecorator('Label');
		
		$form->addElements(array($comment_name,$comment_email,$comment_content,$comment_captcha));
		return $form;
	}