westdc-zf1/application/models/SearchForm.php

45 lines
1.4 KiB
PHP
Raw Normal View History

2009-03-06 03:20:46 +00:00
<?php
class SearchForm extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('search');
$this->setAction('/data/search');
$q = new Zend_Form_Element_Text('q');
$q->setRequired(true)
->addFilter('StringTrim')
->addValidator('NotEmpty');
$spam=new element_bcSpamBlock('spam');
$spam->addPrefixPath('Validator','validator/','validate')
->addValidator('SpamBlock');
$id = new Zend_Form_Element_Hidden('id');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('搜索');
$this->addElements(array($q,$submit,$spam,$id));
$this->clearDecorators();
$this->addDecorator('FormElements')
->addDecorator('HtmlTag', array('tag' => '<ul>'))
->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')),
));
}
}