Skip to content

Instantly share code, notes, and snippets.

@ssmusoke
Created May 10, 2012 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssmusoke/2651027 to your computer and use it in GitHub Desktop.
Save ssmusoke/2651027 to your computer and use it in GitHub Desktop.
Signup form - which does not render
<?php
/**
* Form for adding a signing up a user
*
*/
class SignUpForm extends Zend_Form
{
public function __construct($options = null){
parent::__construct($options);
// options is just a Zend_Config instance passed in when initializing the form
// set the post action url
$this->setAction($options->action)->setMethod(Zend_Form::METHOD_POST);
// set the id and class values
$this->setAttrib('class', 'well form-horizontal')->setAttrib('id', 'signupform');
// form elements
$firstname = new Zend_Form_Element_Text('firstname', array('required' => true, 'label' => getFormLabel('useraccount_firstname_label'),
'value' => $options->firstname,
// validation metadata
'class' => "input-xlarge {required: true, messages: {required: '".translateKey('useraccount_firstname_error')."'}}"));
$lastname = new Zend_Form_Element_Text('lastname', array('required' => true, 'label' => getFormLabel('useraccount_lastname_label'),
'value' => $options->lastname,
// validation metadata
'class' => "input-xlarge {required: true, messages: {required: '".translateKey('useraccount_lastname_error')."'}}"));
$email = new Zend_Form_Element_Text('email', array('required' => true, 'label' => getFormLabel('useraccount_email_label'),
'value' => $options->email,
// validation metadata
'class' => "input-xlarge {required: true, messages: {required: '".translateKey('useraccount_email_error')."'}}"));
$password = new Zend_Form_Element_Password('password', array('required' => true, 'label' => getFormLabel('useraccount_password_label'),
'value' => $options->password,
// validation metadata
'class' => "input-xlarge password {required: true, messages: {required: '".translateKey('useraccount_password_error')."'}}"));
$confirmpassword = new Zend_Form_Element_Password('confirmpassword', array('required' => true, 'label' => getFormLabel('useraccount_password_confirm_label'),
'value' => $options->confirmpassword,
// validation metadata
'class' => "input-xlarge password {required: true, equalTo: '#password', messages: {required: '".translateKey('useraccount_password_confirm_error')."', equalTo: '".translateKey('useraccount_confirmpassword_error_equalto')."'}}"));
$activationkey = new Zend_Form_Element_Hidden('activationkey', array('value' => generateActivationKey()));
$cancel = new Zend_Form_Element_Button('cancel', array('label' => translateKey('global_button_cancel'), 'class' => 'btn-danger'));
$submit = new Zend_Form_Element_Submit('submit', array('label' => $options->submitlabel));
$this->addElements(array($firstname, $lastname, $email, $password, $confirmpassword, $cancel, $submit));
// add the decorator
// set decorators
EasyBib_Form_Decorator::setFormDecorator($this, EasyBib_Form_Decorator::BOOTSTRAP);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment