Created
May 23, 2011 19:27
-
-
Save eminetto/987364 to your computer and use it in GitHub Desktop.
LoginForm
This file contains hidden or 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 LoginForm extends Zend_Form | |
{ | |
public function __construct($options = null) { | |
parent::__construct($options); | |
$this->generate(); | |
} | |
private function generate() { | |
//nome do formulário | |
$this->setName('Login'); | |
//elemento para o campo username | |
$username = new Zend_Form_Element_Text('username'); | |
//configurar o label, dizer q é obrigatório, adicionar um | |
filtro e um validador | |
$username->setLabel('Login') | |
->setRequired(true) | |
->addFilter('StripTags') | |
->addValidator('NotEmpty'); | |
//elemento para a senha | |
$password = new Zend_Form_Element_Password('password'); | |
$password->setLabel('Senha') | |
->setRequired(true) | |
->addFilter('StripTags') | |
->addValidator('NotEmpty'); | |
//botão de submit | |
$submit = new Zend_Form_Element_Submit('submit'); | |
$submit->setLabel('Entrar'); | |
$submit->setAttrib('id', 'Entrar'); | |
//exemplo de class css | |
//$submit->setAttrib('class', 'verde buttonBar'); | |
//adicionar os campos ao formulário | |
$this->addElements(array($username, $password, $submit)); | |
//action e method | |
$this->setAction(BASE_URL.'/index/index')->setMethod('post'); | |
} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment