Created
May 23, 2011 19:28
-
-
Save eminetto/987367 to your computer and use it in GitHub Desktop.
AlbumForm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AlbumForm extends Zend_Form | |
{ | |
public function __construct($options = null) { | |
parent::__construct($options); | |
$this->generate(); | |
} | |
private function generate() { | |
$this->setName('Foto'); | |
$title = new Zend_Form_Element_Text('title'); | |
$title->setLabel('Título')->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty'); | |
$file = new Zend_Form_Element_File('arq'); | |
$file->setLabel('Escolha uma imagem:'); | |
// limite de tamanho | |
$file->addValidator('Size', false, 1024000); | |
// extensões: JPEG, PNG, GIFs | |
$file->addValidator('Extension', false, 'jpg,png,gif'); | |
$submit = new Zend_Form_Element_Submit('submit'); | |
$submit->setLabel('Enviar'); | |
$submit->setName('submit'); | |
//exemplo de class css | |
$this->addElements(array($title, $file, $submit)); | |
//action e method | |
$this->setAction(BASE_URL.'/album')->setMethod('post'); | |
$this->setAttrib('enctype', 'multipart/form-data'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment