Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. <?php
  2.  
  3. class Application_Form_Auth extends Zend_Form
  4. {
  5.  
  6. public function init()
  7. { $this->setAttrib('enctype', 'multipart/form-data');
  8. $this->setMethod('post');
  9.  
  10.  
  11. $username = $this->createElement('text','username');
  12. $username->setLabel('Username:')
  13. ->setRequired(true);
  14.  
  15. $username->setDecorators(array(
  16.  
  17.  
  18.  
  19. 'ViewHelper',
  20.  
  21. 'Description',
  22.  
  23. 'Errors',
  24.  
  25. array(array('data'=>'HtmlTag'), array('tag' => 'td')),
  26.  
  27. array('Label', array('tag' => 'td')),
  28.  
  29. array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
  30.  
  31.  
  32.  
  33. ));
  34.  
  35.  
  36. $password=$this->createElement('password','password');
  37. $password->setLabel('Password:')
  38. ->setRequired(true);
  39.  
  40.  
  41. $password->setDecorators(array(
  42.  
  43.  
  44.  
  45. 'ViewHelper',
  46.  
  47. 'Description',
  48.  
  49. 'Errors',
  50.  
  51. array(array('data'=>'HtmlTag'), array('tag' => 'td')),
  52.  
  53. array('Label', array('tag' => 'td')),
  54.  
  55. array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
  56.  
  57.  
  58.  
  59. ));
  60.  
  61.  
  62.  
  63.  
  64. $file = new Zend_Form_Element_File('file');
  65.  
  66. $file->setLabel('Select File:')
  67.  
  68. ->setDestination(BASE_PATH . '/data/uploads')
  69.  
  70. ->setRequired(true);
  71.  
  72. $file->setDecorators(array(
  73.  
  74.  
  75.  
  76. 'file',
  77.  
  78. 'Description',
  79.  
  80. 'Errors',
  81.  
  82. array(array('data'=>'HtmlTag'), array('tag' => 'td')),
  83.  
  84. array('Label', array('tag' => 'td')),
  85.  
  86. array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
  87.  
  88.  
  89.  
  90. ));
  91.  
  92.  
  93.  
  94.  
  95.  
  96. $captcha = $this->createElement('captcha', 'captcha',
  97. array('required' => true,
  98. 'captcha' => array(
  99. 'captcha' => 'Image',
  100. 'font' => BASE_PATH .'/fonts/Average-Regular.ttf',
  101. 'fontSize' => '24',
  102. 'wordLen' => 5,
  103. 'height' => '75',
  104. 'width' => '200',
  105. 'imgDir'=> BASE_PATH.'/images/captcha',
  106. 'imgUrl'=>'../../images/captcha/',
  107. 'dotNoiseLevel' => 50,
  108. 'lineNoiseLevel' => 5)));
  109.  
  110. $captcha->setLabel('Please type the words shown:');
  111.  
  112.  
  113. $captcha->setDecorators(array(
  114.  
  115.  
  116.  
  117. 'captcha',
  118.  
  119. 'Description',
  120.  
  121. 'Errors',
  122.  
  123. array(array('data'=>'HtmlTag'), array('tag' => 'td')),
  124.  
  125. array('Label', array('tag' => 'td')),
  126.  
  127. array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
  128.  
  129.  
  130.  
  131. ));
  132.  
  133. $form = new ZendX_JQuery_Form();
  134. $date1 = new ZendX_JQuery_Form_Element_DatePicker(
  135. 'date1',
  136. array('label' => 'Date:')
  137. );
  138.  
  139. $date1->setDecorators(array(
  140.  
  141.  
  142.  
  143. 'UiWidgetElement',
  144.  
  145. 'Description',
  146.  
  147. 'Errors',
  148.  
  149. array(array('data'=>'HtmlTag'), array('tag' => 'td')),
  150.  
  151. array('Label', array('tag' => 'td')),
  152.  
  153. array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
  154.  
  155.  
  156.  
  157. ));
  158.  
  159. $reg=$this->createElement('submit','submit');
  160. $reg->setLabel('save');
  161.  
  162. $reg->setDecorators(array(
  163.  
  164.  
  165.  
  166. 'ViewHelper',
  167.  
  168. 'Description',
  169.  
  170. 'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td',
  171.  
  172. 'colspan'=>'2','align'=>'center')),
  173.  
  174. array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
  175.  
  176.  
  177.  
  178. ));
  179.  
  180. $this->setDecorators(array(
  181.  
  182.  
  183.  
  184. 'FormElements',
  185.  
  186. array(array('data'=>'HtmlTag'),array('tag'=>'table')),
  187.  
  188. 'Form'
  189.  
  190.  
  191.  
  192. ));
  193.  
  194.  
  195.  
  196.  
  197. $this->addElements(array(
  198. $username,
  199. $password,
  200. $file,
  201. $captcha,
  202. $date1,
  203. $reg
  204.  
  205. ));
  206.  
  207. $this->addDisplayGroup(array('username', 'password','file','captcha','date1','submit'), 'login',array('legend' =>'Add User'));
  208.  
  209.  
  210.  
  211. $login = $this->getDisplayGroup('login');
  212. $login->setDecorators(array(
  213.  
  214. 'FormElements',
  215. 'Fieldset',
  216.  
  217. array('HtmlTag',array('tag'=>'div','style'=>'width:70%;;float:left; padding-top:5px;'))
  218. ));
  219.  
  220. return $this;
  221. }
  222.  
  223.  
  224. }
  225. ?>
  226.  
  227. <?php
  228.  
  229. echo $this->form->getDisplayGroup('login'); //This form aligned perfectly
  230.  
  231.  
  232. echo $this->form; //This won't
  233.  
  234. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement