zend_form to the rescue - a brief introduction to zend_form
TRANSCRIPT
Zend Form to the Rescue!
A Brief Introduction to Zend_Form
About Me
Jeremy KendallPHP Developer since 2001Organizer Memphis PHP (MemphisPHP.org)Contributor to FRAPI project (getFRAPI.com)
[email protected]@JeremyKendallhttp://jeremykendall.net
Forms in General
Ubiquitous
Tedious
Challenging to get right
Security risk
Primary job responsibility
Typical Form Requirements
Collect data
Filter input
Validate input
Display validation messages
Include default data (ex. List of US States)
Pre-populate fields (for edit/update operations)
Should be easy to test
. . . and more.
Typical PHP Form
Tons of markup
Tons of code
Confusing conditionals
Client side validation likely
Server side validation?
Requires two scripts: form & processor
Not at all easy to test
I could go on and on . . .
Zend Form to the Rescue!
Introduced in ZF 1.5, early 2008
Generates markup
Filters and validates user input
Displays validation advice
Object oriented, easily extended
Completely customizable
Can be used apart from ZF MVC
Easy to test
Standard Form Elements
Button
Captcha
Checkbox
File
Hidden
Hash
Image
MultiCheckbox
MultiSelect
Password
Radio
Reset
Select
Text
TextArea
Standard Filter Classes
Alnum
Alpha
Basename
Boolean
HtmlEntities
StringToLower
StringToUpper
StringTrim
And many more . . .
Standard Validation Classes
Alnum
Alpha
Barcode
Between
Callback
CreditCard
Date
DbRecordExists
NoRecordExists
Digits
EmailAddress
File
Float
GreaterThan
Hex
Hostname
Iban
Identical
And many more . . .
Simple Contact Form
Default Markup
Your name . . .
What does it look like?
How about with errors?
Can I use Zend Form by itself?
Standalone - library/base.php