Advertisement
RalfEggert

UserForm

Aug 27th, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.18 KB | None | 0 0
  1. <?php
  2. namespace User\Form;
  3.  
  4. use Zend\Form\Form;
  5. use Zend\Form\Element;
  6.  
  7. class UserSaveForm extends Form
  8. {
  9.     /**
  10.      * Create the form
  11.      *
  12.      * @param string $name Optional name for the form
  13.      */
  14.     public function __construct($name = null)
  15.     {
  16.         // call constructor
  17.         parent::__construct($name);
  18.        
  19.         // set attributes
  20.         $this->setAttribute('method', 'post');
  21.        
  22.         // add id
  23.         $this->add(array(
  24.             'name' => 'id',
  25.             'type' => 'Zend\Form\Element\Hidden',
  26.         ));
  27.        
  28.         // add nickname
  29.         $this->add(array(
  30.             'name'       => 'nickname',
  31.             'type'       => 'Zend\Form\Element\Text',
  32.             'attributes' => array('maxlength' => '32', 'size' => '32'),
  33.             'options'    => array('label' => 'label_user_nickname'),
  34.         ));
  35.        
  36.         // add password
  37.         $this->add(array(
  38.             'name' => 'password',
  39.             'type' => 'Zend\Form\Element\Password',
  40.             'attributes' => array('maxlength' => '128', 'size' => '32'),
  41.             'options' => array('label' => 'label_user_password'),
  42.         ));
  43.    
  44.         // add email
  45.         $this->add(array(
  46.             'name' => 'email',
  47.             'type' => 'Zend\Form\Element\Email',
  48.             'attributes' => array('maxlength' => '128', 'size' => '32'),
  49.             'options' => array('label' => 'label_user_email', 'appendText' => '@'),
  50.         ));
  51.    
  52.         // add status
  53.         $this->add(array(
  54.             'name'       => 'status',
  55.             'type'       => 'Zend\Form\Element\Select',
  56.             'attributes' => array('options' => array()),
  57.             'options'    => array('label' => 'label_user_status'),
  58.         ));
  59.        
  60.         // add group
  61.         $this->add(array(
  62.             'name'       => 'group',
  63.             'type'       => 'Zend\Form\Element\Select',
  64.             'attributes' => array('options' => array()),
  65.             'options'    => array('label' => 'label_user_group'),
  66.         ));
  67.        
  68.         // add firstname
  69.         $this->add(array(
  70.             'name'       => 'firstname',
  71.             'type'       => 'Zend\Form\Element\Text',
  72.             'attributes' => array('maxlength' => '64', 'size' => '32'),
  73.             'options'    => array('label' => 'label_user_firstname'),
  74.         ));
  75.        
  76.         // add lastname
  77.         $this->add(array(
  78.             'name'       => 'lastname',
  79.             'type'       => 'Zend\Form\Element\Text',
  80.             'attributes' => array('maxlength' => '64', 'size' => '32'),
  81.             'options'    => array('label' => 'label_user_lastname'),
  82.         ));
  83.        
  84.         // Submit button
  85.         $this->add(array(
  86.             'name' => 'submit_user_save',
  87.             'type' => 'Zend\Form\Element\Submit',
  88.             'attributes' => array('value' => 'submit_user_save'),
  89.             'options' => array(),
  90.         ));
  91.         // Submit button
  92.         $this->add(array(
  93.             'name' => 'submit_user_list',
  94.             'type' => 'Zend\Form\Element\Submit',
  95.             'attributes' => array('value' => 'submit_user_cancel'),
  96.             'options' => array(),
  97.         ));
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement