Created
March 4, 2009 22:19
-
-
Save derekr/74045 to your computer and use it in GitHub Desktop.
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 Model_Form_Login extends Zend_Form | |
{ | |
protected $_actionUrl; | |
public function __construct($actionUrl = null, $options=null) | |
{ | |
parent::__construct($options); | |
$this->setActionUrl($actionUrl); | |
$this->init(); | |
} | |
public function setActionUrl($actionUrl) | |
{ | |
$this->_actionUrl = $actionUrl; | |
return $this; | |
} | |
public function init() | |
{ | |
$this->setAction($this->_actionUrl) | |
->setMethod('post') | |
->setAttrib('id', 'login-form'); | |
$this->setDisableLoadDefaultDecorators(true); | |
$this->setDecorators( | |
array( | |
'FormElements', array( | |
'HtmlTag', array( | |
'tag' => 'fieldset' | |
) | |
), | |
'Form' | |
) | |
); | |
$decorators = array( | |
array('ViewHelper'), | |
array('Errors'), | |
array('Label', array( | |
'class' => 'left-aligned' | |
)), | |
array('HtmlTag', array( | |
'tag' => 'div', | |
'class' => 'field' | |
)) | |
); | |
$this->addElementPrefixPath('JobTracking_Validate', 'JobTracking/Validate/', 'validate'); | |
$empty = new Zend_Validate_NotEmpty(); | |
$empty->setMessage('Ahhhhh! I am empty!'); | |
$this->addElement('hidden', 'redirectUrl'); | |
$redirectUrl = $this->getElement('redirectUrl'); | |
$redirectUrl->clearDecorators(); | |
$this->addElement('text', 'username', array('label' => 'Username')); | |
$username = $this->getElement('username') | |
->addValidator($empty, true) | |
->addValidator('alnum') | |
->setRequired(true, true) | |
->addFilter('StringTrim') | |
->addValidator('EmployeeAuthorise'); | |
$username->getValidator('alnum')->setMessage( | |
'Quit putting funky characters in your username! We only accept letters and numbers.'); | |
$username->setDecorators($decorators); | |
$this->addElement('password', 'password', array('label' => 'Password')); | |
$password = $this->getElement('password') | |
->addValidator($empty, true) | |
->setRequired(true, true) | |
->addFilter('StringTrim'); | |
$password->setDecorators($decorators); | |
$submit = $this->addElement('button', 'login', array('label' => 'Login')); | |
// tried this: $submit->removeDecorator('DtDdWrapper'); | |
// and this: $submit->setDisableLoadDefaultDecorators(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment