westdc-zf1/application/models/DatafeatureForm.php

44 lines
1.6 KiB
PHP

<?php
class DatafeatureForm extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('Datafeature');
$title = new Zend_Form_Element_Text('title');
$title->setLabel('标题')->setRequired(true)
->addFilter('StripTags') ->addFilter('StringTrim');
$detailurl=new Zend_Form_Element_Text('detailurl');
$detailurl->setLabel('详细地址')
->setRequired(true)
->addFilter('StringTrim')
->addValidator('NotEmpty');
$imgurl=new Zend_Form_Element_Text('imgurl');
$imgurl->setLabel('图片地址')
->setRequired(false)
->addFilter('StringTrim')
->addValidator('NotEmpty');
$img=new Zend_Form_Element_File('img');
$img->setLabel('或者上传图片')
//->setRequired(true)
->setDestination('images')
->addValidator('Count', false, 1) // ensure only 1 file
->addValidator('Size', false, 102400) // limit to 100K
->addValidator('Extension', false, 'jpg,png,gif'); // only JPEG, PNG, and GIFs
$description=new Zend_Form_Element_Textarea('description');
$description->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('发送');
$this->setAttrib('enctype', 'multipart/form-data');
$this->addElements(array($id, $title,$detailurl,$imgurl,$img,$description,$submit));
}
}