50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
class LoginForm extends Zend_Form
|
||
|
{
|
||
|
public function __construct($options = null)
|
||
|
{
|
||
|
parent::__construct($options);
|
||
|
$this->setName('login');
|
||
|
|
||
|
$username = new Zend_Form_Element_Text('username');
|
||
|
$username->setLabel('用户名')
|
||
|
->setRequired(true)
|
||
|
->addFilter('StripTags')
|
||
|
->addFilter('StringTrim')
|
||
|
->addValidator('NotEmpty');
|
||
|
|
||
|
$password=new Zend_Form_Element_Password('password');
|
||
|
$password->setLabel('密码')->setRequired(true);
|
||
|
|
||
|
$remember=new Zend_Form_Element_Checkbox('remember');
|
||
|
$remember->setLabel('记住我');
|
||
|
$id = new Zend_Form_Element_Hidden('id');
|
||
|
|
||
|
$submit = new Zend_Form_Element_Submit('submit');
|
||
|
$submit->setLabel('登录');
|
||
|
$submit->setAttrib('id', 'submitbutton');
|
||
|
|
||
|
$this->addElements(array($id, $username, $password, $remember, $submit));
|
||
|
$this->clearDecorators();
|
||
|
$this->addDecorator('FormElements')
|
||
|
->addDecorator('HtmlTag', array('tag' => '<ul>','class'=>'loginform'))
|
||
|
->addDecorator('Form');
|
||
|
|
||
|
$this->setElementDecorators(array(
|
||
|
array('ViewHelper'),
|
||
|
array('Errors'),
|
||
|
array('Description'),
|
||
|
array('Label', array('separator'=>' ')),
|
||
|
array('HtmlTag', array('tag' => 'li', 'class'=>'element-group')),
|
||
|
));
|
||
|
|
||
|
// buttons do not need labels
|
||
|
$submit->setDecorators(array(
|
||
|
array('ViewHelper'),
|
||
|
array('Description'),
|
||
|
array('HtmlTag', array('tag' => 'li', 'class'=>'submit-group')),
|
||
|
));
|
||
|
|
||
|
}
|
||
|
}
|