Guest User

Untitled

a guest
Jul 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <?php
  2.  
  3. public function action_new()
  4. {
  5. $form = array
  6. (
  7. 'kudo_category_id' => NULL,
  8. 'tags' => ''
  9. );
  10.  
  11. if ($_POST)
  12. {
  13. $form = Arr::overwrite($form, $_POST);
  14.  
  15. // create a kudo template
  16. $kudo_template = ORM::factory('kudo_template');
  17.  
  18. $kudo_template->values(Arr::merge($form, $_FILES));
  19.  
  20. if ($kudo_template->check())
  21. {
  22. try
  23. {
  24. $kudo_template->save();
  25. $this->request->redirect(URL::site('admin/kudo_templates'));
  26. }
  27. catch (Exception $e)
  28. {
  29. throw new Kohana_Exception($e->getMessage());
  30. }
  31. }
  32. else
  33. {
  34. $errors = $kudo_template->validate()->errors('kudo_template');
  35. }
  36. }
  37.  
  38. // get kudo categories for form dropdown
  39. $kudo_categories = ORM::factory('kudo_category')->order_by('name', 'ASC')->find_all();
  40.  
  41. $this->template->title[] = 'New Kudo Template';
  42. $this->template->content = View::factory('admin/kudo_templates/new')
  43. ->set('form', $form)
  44. ->set('kudo_categories', $kudo_categories)
  45. ->set('errors', isset($errors) ? $errors : array());
  46. }
Add Comment
Please, Sign In to add comment