Advertisement
Guest User

Untitled

a guest
May 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class Admin_Form_User extends Zend_Form {
  5.  
  6. public function init() {
  7.  
  8. // parent::init();
  9. // $this->addPrefixPath('Admin_Form', 'Admin/Form')->addElementPrefixPath('Admin', 'Valiate');
  10.  
  11. // Set the method for the display form to POST
  12. $this->setMethod('post');
  13. $this->setName('user_create');
  14.  
  15. // Add userID as a hidden
  16. // Add a user name element
  17. $this->addElement('hidden', 'id', array(
  18. ));
  19.  
  20. // validator on user name to not contain any special charectors
  21. $validator = new Zend_Validate_Regex('([A-Za-z0-9]+)');
  22. $validator->setMessage(
  23. 'Your username can only contain letters, numbers and underscores (_).');
  24.  
  25. // Add a user name element
  26. $this->addElement('text', 'username', array(
  27. 'label' => 'Username:',
  28. 'required' => true,
  29. 'filters' => array('StringTrim'),
  30. 'class' => 'txt-input medium validate(required, username, rangelength(5,50))',
  31. 'validators' => array(
  32. array('StringLength', false, array(5, 50))
  33. ),
  34. ));
  35.  
  36. // Password Validation
  37. $passwordConfirmation = new Admin_Form_Validate_Password();
  38.  
  39. // Add a password element
  40. $this->addElement('password', 'password', array(
  41. 'label' => 'Password:',
  42. 'required' => true,
  43. 'filters' => array('StringTrim'),
  44. 'class' => 'validate(required, rangelength(5,50)) txt-input medium',
  45. 'validators' => array(
  46. $passwordConfirmation,
  47. array('Alnum'),
  48. array('StringLength', false, array(5, 50)),
  49. ),
  50. ));
  51.  
  52. // Add a re-password element
  53. $this->addElement('password', 'password_confirm', array(
  54. 'label' => 'Confirm password:',
  55. 'required' => true,
  56. 'filters' => array('StringTrim'),
  57. 'class' => 'validate(required, rangelength(5,50), match(#password)) txt-input medium',
  58. 'validators' => array(
  59. $passwordConfirmation,
  60. array('Alnum'),
  61. array('StringLength', false, array(6, 100)),
  62. ),
  63. ));
  64.  
  65. // Add an email element
  66. $this->addElement('text', 'email', array(
  67. 'label' => 'Email address:',
  68. 'required' => true,
  69. 'filters' => array('StringTrim'),
  70. 'validators' => array(
  71. 'EmailAddress',
  72. ),
  73. 'class' => 'validate(email) txt-input medium'
  74. ));
  75.  
  76. // // Add a first name element
  77. // $this->addElement('text', 'fname', array(
  78. // 'label' => 'Full Name:',
  79. // 'required' => true,
  80. // 'filters' => array('StringTrim'),
  81. // 'class' => 'txt-input medium'
  82. // ));
  83.  
  84. // Add a role element
  85. $this->addElement('select', 'type', array(
  86. 'label' => 'User type:',
  87. 'required' => true,
  88. 'filters' => array('StringTrim'),
  89. 'class' => 'validate(required) select-input small',
  90. 'multioptions' => array('CP'=>'Content Provider', 'ADMIN'=>'Administrator', 'USER'=>'User')
  91. ));
  92.  
  93. // Add an status element
  94. $this->addElement('checkbox', 'status', array(
  95. 'label' => 'Active?:',
  96. 'value' => true
  97. ));
  98.  
  99. // Add a notify element
  100. $this->addElement('checkbox', 'notify', array(
  101. 'label' => 'Notify to user:',
  102. ));
  103.  
  104. // Add the submit button
  105. $this->addElement('submit', 'submit', array(
  106. 'ignore' => true,
  107. 'label' => 'Create User',
  108. 'class' => 'txt-input small'
  109. ));
  110.  
  111. // And finally add some CSRF protection
  112. $this->addElement('hash', 'csrf', array(
  113. 'ignore' => true,
  114. ));
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement