westdc-zf1/application/models/SearchForm.php

41 lines
1.2 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('/search');
$this->setMethod('get');
2009-03-06 03:20:46 +00:00
$q = new Zend_Form_Element_Text('q');
$q->setRequired(true)
->addFilter('StringTrim')
->addValidator('NotEmpty');
2009-11-27 14:20:19 +00:00
2009-03-06 03:20:46 +00:00
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('搜索');
2009-11-27 14:20:19 +00:00
$this->addElements(array($q,$submit));
2009-03-06 03:20:46 +00:00
$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')),
));
}
}