Advertisement
Guest User

Untitled

a guest
Aug 15th, 2011
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2.     class Application_Form_Guestbook extends Zend_Form
  3.     {
  4.         public function init()
  5.         {
  6.             // Set the method for the display form to POST
  7.             $this->setMethod('post');
  8.      
  9.             // Add an email element
  10.             $this->addElement('text', 'email', array(
  11.                 'label'      => 'Your email address:',
  12.                 'required'   => true,
  13.                 'filters'    => array('StringTrim'),
  14.                 'validators' => array(
  15.                     'EmailAddress',
  16.                 )
  17.             ));
  18.      
  19.             // Add the comment element
  20.             $this->addElement('textarea', 'comment', array(
  21.                 'label'      => 'Please Comment:',
  22.                 'required'   => true,
  23.                 'validators' => array(
  24.                     array('validator' => 'StringLength', 'options' => array(0, 20))
  25.                     )
  26.             ));
  27.      
  28.             // Add a captcha
  29.             $this->addElement('captcha', 'captcha', array(
  30.                 'label'      => 'Please enter the 5 letters displayed below:',
  31.                 'required'   => true,
  32.                 'captcha'    => array(
  33.                     'captcha' => 'Figlet',
  34.                     'wordLen' => 5,
  35.                     'timeout' => 300
  36.                 )
  37.             ));
  38.      
  39.             // Add the submit button
  40.             $this->addElement('submit', 'submit', array(
  41.                 'ignore'   => true,
  42.                 'label'    => 'Sign Guestbook',
  43.             ));
  44.      
  45.             // And finally add some CSRF protection
  46.             $this->addElement('hash', 'csrf', array(
  47.                 'ignore' => true,
  48.             ));
  49.         }
  50.     }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement