Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Jeremy Kendall

By: a guest on Jul 23rd, 2010  |  syntax: PHP  |  size: 1.65 KB  |  views: 438  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. class Application_Form_Example extends Zend_Form
  4. {
  5.    
  6.     public function init()
  7.     {
  8.        
  9.         $this->addElement('text', 'firstName', array(
  10.             'required' => true,
  11.             'label'    => 'First Name',
  12.             'validators' => array('Alnum')
  13.         ));
  14.        
  15.         $this->addElement('text', 'lastName', array(
  16.             'required' => true,
  17.             'label'    => 'Last Name',
  18.             'validators' => array('Alnum')
  19.         ));
  20.        
  21.         $this->addElement('text', 'email', array(
  22.             'label'    => 'Email Address',
  23.             'validators' => array('EmailAddress')
  24.         ));
  25.        
  26.         $this->addElement('radio', 'tree', array(
  27.             'required' => true,
  28.             'label'    => 'Are you a tree?',
  29.             'multiOptions' => array('yes' => 'Yes', 'no' => 'No'),
  30.             'validators' => array(new Zend_Validate_InArray(array('yes', 'no')))
  31.         ));
  32.        
  33.         $this->addElement('multiCheckbox', 'interests', array(
  34.             'label' => 'Interests (check all that apply)',
  35.             'required' => true,
  36.         ));
  37.        
  38.         $this->addElement('select', 'referral', array(
  39.             'label' => 'How did you hear about us?',
  40.             'required' => true
  41.         ));
  42.        
  43.         $this->addElement('textarea', 'comments', array(
  44.             'label' => 'Comments',
  45.             'cols' => '30',
  46.             'rows' => '5'
  47.         ));
  48.        
  49.         $this->addElement('submit', 'Submit');
  50.  
  51.         // Sets specified filters on all elements in the form
  52.         $this->setElementFilters(array('StripTags', 'StringTrim'));
  53.        
  54.     }
  55. }