41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
class ContactForm extends Zend_Form
|
||
|
{
|
||
|
public function __construct($options = null)
|
||
|
{
|
||
|
parent::__construct($options);
|
||
|
$this->setName('Contact');
|
||
|
|
||
|
$username = new Zend_Form_Element_Text('username');
|
||
|
$username->setLabel('用户名')->setRequired(true)
|
||
|
->addFilter('StripTags') ->addFilter('StringTrim')
|
||
|
->addValidator('StringLength',false,array(3,50));
|
||
|
|
||
|
|
||
|
$email=new Zend_Form_Element_Text('email');
|
||
|
$email->setLabel('E-Mail')
|
||
|
->setRequired(true)
|
||
|
->addFilter('StringTrim')
|
||
|
->addValidator('NotEmpty')
|
||
|
->addValidator('EmailAddress');
|
||
|
|
||
|
$subject=new Zend_Form_Element_Text('subject');
|
||
|
$subject->setLabel('主题')->setRequired(true);
|
||
|
|
||
|
$body=new Zend_Form_Element_Textarea('body');
|
||
|
$body->setLabel('内容')->setRequired(true)->setAttrib('rows',4);
|
||
|
|
||
|
$id = new Zend_Form_Element_Hidden('id');
|
||
|
|
||
|
$submit = new Zend_Form_Element_Submit('submit');
|
||
|
$submit->setAttrib('id', 'submitbutton')->setLabel('发送');
|
||
|
|
||
|
$spam=new element_bcSpamBlock('spam');
|
||
|
$spam->addPrefixPath('Validator','validator/','validate')
|
||
|
->addValidator('SpamBlock');
|
||
|
|
||
|
|
||
|
$this->addElements(array($id, $spam,$username,$email,$subject,$body,$submit));
|
||
|
}
|
||
|
}
|