westdc-zf1/application/models/SearchForm.php

40 lines
1.2 KiB
PHP
Executable File

<?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');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('搜索');
$this->addElements(array($q,$submit));
$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')),
));
}
}