editTimeForm.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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","15"=>"15 Minutes"));
  26. $timeCodes = new codeModel();
  27. $code = new Staple_Form_FoundationSelectElement('code','Code');
  28. $code->setRequired()
  29. ->addOptionsArray($timeCodes->allCodes());
  30. $submit = new Staple_Form_FoundationSubmitElement('submit','Update');
  31. $submit->addClass('button success expand radius');
  32. $this->addField($date, $inTime, $outTime, $lessTime, $code, $submit);
  33. }
  34. }
  35. ?>