Advertisement
Guest User

Untitled

a guest
May 29th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.37 KB | None | 0 0
  1. /**
  2. * Initialize form (extended from HouseSimple_Form)
  3. *
  4. * @return void
  5. */
  6. public function init()
  7. {
  8. $this->setMethod('post');
  9. $this->setAttrib('class', 'Form Form--user');
  10. $this->setAction($this->getView()->url());
  11.  
  12. // Contact details.
  13. $this->addElement('Select', 'title', array(
  14. 'label' => 'Title',
  15. 'required' => true,
  16. 'multiOptions' => array(
  17. '' => '',
  18. 'mr' => 'Mr',
  19. 'mrs' => 'Mrs',
  20. 'miss' => 'Miss',
  21. 'ms' => 'Ms',
  22. 'dr' => 'Dr',
  23. ),
  24. 'gridCellClasses' => array('u-size1of6', 'u-sm-size1of3')
  25. ));
  26.  
  27. $this->addElement('Text', 'firstName', array(
  28. 'label' => 'First Name',
  29. 'required' => true,
  30. 'errorMessage' => 'Please enter your first name',
  31. 'filters' => array('StripTags', 'StringTrim'),
  32. 'gridCellClasses' => array('u-size1of3', 'u-sm-size2of3')
  33. ));
  34.  
  35. $this->addElement('Text', 'surname', array(
  36. 'label' => 'Surname',
  37. 'required' => true,
  38. 'errorMessage' => 'Please enter your surname',
  39. 'filters' => array('StripTags', 'StringTrim'),
  40. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  41. ));
  42.  
  43. $this->addElement('Text', 'telephone', array(
  44. 'label' => 'Telephone',
  45. 'required' => true,
  46. 'errorMessage' => 'Please enter a valid phone number',
  47. 'filters' => array('StripTags', 'StringTrim'),
  48. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  49. ));
  50.  
  51. $this->addElement('Text', 'mobile', array(
  52. 'label' => 'Mobile Telephone',
  53. 'required' => true,
  54. 'errorMessage' => 'Please enter a valid phone number',
  55. 'filters' => array('StripTags', 'StringTrim'),
  56. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  57. ));
  58.  
  59. $this->addDisplayGroup(
  60. array(
  61. 'title',
  62. 'firstName',
  63. 'surname',
  64. 'telephone',
  65. 'mobile'
  66. ),
  67. 'contactDetails',
  68. array('legend' => 'Your details')
  69. );
  70.  
  71. // Email fields.
  72. $this->addElement('Text', 'email', array(
  73. 'label' => 'Email',
  74. 'required' => true,
  75. 'errorMessage' => 'Please enter a valid email address',
  76. 'filters' => array('StripTags', 'StringTrim'),
  77. 'validators' => array(
  78. array(new Caboodle_Validate_UniqueEmail(array(
  79. 'message' => "'%value%' is already registered"
  80. )), true),
  81. array(new Zend_Validate_EmailAddress(array(
  82. 'messages' => array(
  83. Zend_Validate_EmailAddress::INVALID => 'Invalid email address',
  84. Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid email address',
  85. Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Invalid email address',
  86. Zend_Validate_EmailAddress::INVALID_LOCAL_PART => 'Invalid email address',
  87. Zend_Validate_EmailAddress::INVALID_MX_RECORD => 'Invalid email address',
  88. Zend_Validate_EmailAddress::INVALID_SEGMENT => 'Invalid email address'
  89. )
  90. )), true)
  91. ),
  92. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  93. ));
  94.  
  95. $this->addElement('Text', 'confirmEmail', array(
  96. 'label' => 'Confirm Email',
  97. 'required' => true,
  98. 'errorMessage' => 'my-details-error-message-email-confirm',
  99. 'filters' => array('StripTags', 'StringTrim'),
  100. 'validators' => array(array(new Caboodle_Validate_ConfirmEmailMatch(), true)),
  101. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  102. ));
  103.  
  104. $this->addDisplayGroup(
  105. array(
  106. 'email',
  107. 'confirmEmail'
  108. ),
  109. 'emailFields'
  110. );
  111.  
  112. // Password fields.
  113. $this->addElement('password', 'password', array(
  114. 'label' => 'Choose Password',
  115. 'required' => true,
  116. 'errorMessage' => 'Password must be a minimum of 6 characters',
  117. 'filters' => array('StripTags', 'StringTrim'),
  118. 'validators' => array(array(new Zend_Validate_StringLength(array('min' => 6)), true)),
  119. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  120. ));
  121.  
  122. $this->addElement('password', 'confirmPassword', array(
  123. 'label' => 'Confirm Password',
  124. 'required' => true,
  125. 'errorMessage' => 'Password must match',
  126. 'filters' => array('StripTags', 'StringTrim'),
  127. 'validators' => array(array(new Caboodle_Validate_ConfirmPasswordMatch(), true)),
  128. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
  129. ));
  130.  
  131. $this->addDisplayGroup(
  132. array(
  133. 'password',
  134. 'confirmPassword'
  135. ),
  136. 'passwordFields'
  137. );
  138.  
  139. // Address fields.
  140. $this->addElement('Text', 'buildingNameNumber', array(
  141. 'label' => 'Building name or number',
  142. 'required' => true,
  143. 'errorMessage' => 'Please enter your building name or number',
  144. 'filters' => array('StripTags', 'StringTrim'),
  145. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
  146. 'attribs' => array('data-address-field' => 'buildingNameNumber')
  147. ));
  148.  
  149. $this->addElement('Text', 'street', array(
  150. 'label' => 'Street',
  151. 'required' => true,
  152. 'errorMessage' => 'Please enter your street',
  153. 'filters' => array('StripTags', 'StringTrim'),
  154. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
  155. 'attribs' => array('data-address-field' => 'street')
  156. ));
  157.  
  158. $this->addElement('Text', 'town', array(
  159. 'label' => 'Town',
  160. 'required' => true,
  161. 'errorMessage' => 'Please enter your town',
  162. 'filters' => array('StripTags', 'StringTrim'),
  163. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
  164. 'attribs' => array('data-address-field' => 'town')
  165. ));
  166.  
  167. $geoData = new Services_Model_DbTable_PostCodeData();
  168. $result = $geoData->getAllCounties();
  169. $counties = array('' => '-- Choose -- ');
  170. foreach ($result as $value) {
  171. $counties[trim($value->county)] = trim($value->county);
  172. }
  173.  
  174. $this->addElement('Select', 'county', array(
  175. 'label' => 'County',
  176. 'required' => true,
  177. 'errorMessage' => 'Please enter a valid county',
  178. 'multiOptions' => $counties,
  179. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
  180. 'attribs' => array('data-address-field' => 'county')
  181. ));
  182.  
  183. $this->addElement('Text', 'postcode', array(
  184. 'label' => 'Postcode',
  185. 'required' => true,
  186. 'errorMessage' => 'Please enter a valid postcode',
  187. 'validators' => array(array('PostCode', true)),
  188. 'filters' => array('StripTags', 'StringTrim'),
  189. 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
  190. 'attribs' => array('data-address-field' => 'postcode')
  191. ));
  192.  
  193. $this->addDisplayGroup(
  194. array(
  195. 'buildingNameNumber',
  196. 'street',
  197. 'town',
  198. 'county',
  199. 'postcode'
  200. ),
  201. 'address',
  202. array('inline' => true, 'legend' => 'Your address')
  203. );
  204.  
  205. // Signup interests.
  206. $this->addElement('MultiCheckbox', 'interests', array(
  207. 'multiOptions' => Hs_Model_User::getSignupInterests(),
  208. 'separator' => '',
  209. 'inline' => true
  210. ));
  211.  
  212. $this->addDisplayGroup(
  213. array('interests'),
  214. 'userInterests',
  215. array('legend' => 'Your Interests')
  216. );
  217.  
  218. // Buttons.
  219. $this->addElement('Button', 'save_btn', array(
  220. 'label' => 'Submit'
  221. ));
  222.  
  223. $this->addDisplayGroup(
  224. array('save_btn'),
  225. 'buttons',
  226. array('order' => 500)
  227. );
  228.  
  229. parent::init();
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement