Here's what I'd like:
Here's my code:
<?php
require_once ('Zend\Form.php');
class Sergio_Form_registrationform extends Zend_Form {
public function init(){
/*********************USERNAME**********************/
$username = new Zend_Form_Element_Text('username');
$alnumValidator = new Zend_Validate_Alnum();
$username ->setRequired(true)
->setLabel('Username:')
->addFilter('StringToLower')
->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength',false,array(6,20));
$this->addElement($username);
/*********************EMAIL**********************/
$email = new Zend_Form_Element_Text('email');
$alnumValidator = new Zend_Validate_Alnum();
$email ->setRequired(true)
->setLabel('EMail:')
->addFilter('StringToLower')
->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength',false,array(6,20));
$this->addElement($email);
/*********************PASSWORD**********************/
$password = new Zend_Form_Element_Password('password');
$alnumValidator = new Zend_Validate_Alnum();
$password ->setRequired(true)
->setLabel('Password:')
->addFilter('StringToLower')
->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength',false,array(6,20));
$this->addElement($password);
/*********************PASSWORD-CONFIRM**********************/
$passwordc = new Zend_Form_Element_Password('passwordc');
$alnumValidator = new Zend_Validate_Alnum();
$passwordc ->setRequired(true)
->setLabel('Confirm Password:')
->addFilter('StringToLower')
->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength',false,array(6,20));
$this->addElement($passwordc);
/*********************NAME**********************/
$name = new Zend_Form_Element_Text('name');
$alnumValidator = new Zend_Validate_Alnum();
$name ->setRequired(true)
->setLabel('Name:')
->addFilter('StringToLower')
->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength',false,array(6,20));
$this->addElement($name);
/*********************AVATAR**********************/
$avatar = new Zend_Form_Element_File('avatar');
$alnumValidator = new Zend_Validate_Alnum();
$avatar ->setRequired(true)
->setLabel('Please select a display picture:');
$this->addElement($avatar);
/*********************SUBMIT**********************/
$this->addElement('submit', 'login', array('label' => 'Login'));
}
}
?>
And in my View, here's the code I use to show the previous form:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Thank you for signing up!</title>
<style type="text/css">
#imageSignUp img{
float: right;
padding: 3em;
}
</style>
</head>
<body>
<h1>Thanks for signing up!</h1>
<?php
echo $this->form;
?>
<img alt="signupimg" src="/img/signup.png">
</body>
</html>