Guest User

Untitled

a guest
May 23rd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. function getEditForm($id) {
  2. // Create a validator
  3. $validator = new RequiredFields('Name', 'Price');
  4.  
  5. $record = new Booking();
  6. // Create form actions & required fields
  7. switch($id) {
  8. case 'new':
  9. $actions = new FieldSet(
  10. new FormAction('doSaveLink', "Save Booking")
  11. );
  12. break;
  13. case 'buy':
  14. $actions = new FieldSet(
  15. new FormAction('doAddVoucher', "Add Voucher To Cart")
  16. );
  17. $validator = new RequiredFields('Title', 'FirstName', 'Surname', 'DOB', 'Email', 'PostCode', 'Address', 'Address2', 'City', 'Country', 'Tel1');
  18. break;
  19. case 'redeem':
  20. break;
  21. default:
  22. $record = DataObject::get_by_id('Booking', $id);
  23. $actions = new FieldSet(
  24. new FormAction('doUpdateLink', "Update Booking")
  25. );
  26. break;
  27. }
  28.  
  29. $fields = $record->getCMSFields($id);
  30.  
  31. $form = new Form($this, "EditForm", $fields, $actions, $validator);
Add Comment
Please, Sign In to add comment