Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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);
- }
- }
Add Comment
Please, Sign In to add comment