editTimeForm.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. class editTimeForm extends Staple_Form
  3. {
  4. public function _start()
  5. {
  6. $this->setLayout('editFormLayout');
  7. $this->setName('editTimeForm');
  8. $date = new Staple_Form_FoundationTextElement('date','Date');
  9. $date->setRequired()
  10. ->addValidator(new Staple_Form_Validate_Length('1','10'))
  11. ->addValidator(new Staple_Form_Validate_Date())
  12. ->addAttrib('placeholder','mm/dd/yyyy');
  13. $inTime = new Staple_Form_FoundationTextElement('inTime','Time In');
  14. $inTime->setRequired()
  15. ->addValidator(new Staple_Form_Validate_Length('1','8'))
  16. ->addValidator(new Staple_Form_Validate_Regex('/^(0|[0-9]|1[012]):[0-5][0-9] ?((a|p)m|(A|P)M)$/','Invalid time format. Expected format: h:mm am/pm.'))
  17. ->addAttrib('placeholder','h:mm am/pm');
  18. $outTime = new Staple_Form_FoundationTextElement('outTime','Time Out');
  19. $outTime->setRequired()
  20. ->addValidator(new Staple_Form_Validate_Length('1','8'))
  21. ->addValidator(new Staple_Form_Validate_Regex('/^(0|[0-9]|1[012]):[0-5][0-9] ?((a|p)m|(A|P)M)$/','Invalid time format. Expected format: h:mm am/pm.'))
  22. ->addAttrib('placeholder','h:mm am/pm');;
  23. $lessTime = new Staple_Form_FoundationSelectElement('lessTime','Less Time');
  24. $lessTime->setRequired()
  25. ->addOptionsArray(array("0"=>"None","60"=>"1 Hour","30"=>"30 Minutes"))
  26. ->addValidator(new Staple_Form_Validate_InArray(array('0','60','30')));
  27. $timeCodes = new codeModel();
  28. $code = new Staple_Form_FoundationSelectElement('code','Code');
  29. $code->setRequired()
  30. ->addOptionsArray($timeCodes->allCodes());
  31. $submit = new Staple_Form_FoundationSubmitElement('submit','Update');
  32. $submit->addClass('button success expand radius');
  33. $this->addField($date, $inTime, $outTime, $lessTime, $code, $submit);
  34. }
  35. }
  36. ?>