Skip to content

Instantly share code, notes, and snippets.

@settermjd
Created January 15, 2014 04:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save settermjd/8430918 to your computer and use it in GitHub Desktop.
Save settermjd/8430918 to your computer and use it in GitHub Desktop.
A Zend Form created via annotations, modelling a very simple user record.
<?php
namespace MyApplication\Form;
use Zend\Form\Annotation;
/**
* @Annotation\Name("user")
* @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
*/
class UserRecord
{
/**
* @Annotation\Exclude()
*/
public $id;
/**
* @Annotation\Filter({"name":"StringTrim"})
* @Annotation\Validator({"name":"StringLength", "options":{"min":1, "max":25}})
* @Annotation\Validator({"name":"Regex", "options":{"pattern":"/^[a-zA-Z][a-zA-Z0-9_-]{0,24}$/"}})
* @Annotation\Attributes({"type":"text"})
* @Annotation\Options({"label":"Username:"})
*/
public $username;
/**
* @Annotation\Filter({"name":"StringTrim"})
* @Annotation\Validator({"name":"StringLength", "options":{"min":1, "max":25}})
* @Annotation\Attributes({"type":"text"})
* @Annotation\Options({"label":"Password:"})
* @Annotation\Type("Zend\Form\Element\Password")
*/
public $password;
/**
* @Annotation\Type("Zend\Form\Element\Email")
* @Annotation\Options({"label":"Email Address:"})
*/
public $email;
/**
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Options({"label":"Phone Number:"})
*/
public $phoneNumber;
/**
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Options({"label":"Social Security Number:"})
*/
public $ssn;
/**
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Options({"label":"First Name:"})
*/
public $firstName;
/**
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Options({"label":"Last Name:"})
*/
public $lastName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment