Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function action_new()
- {
- $form = array
- (
- 'kudo_category_id' => NULL,
- 'tags' => ''
- );
- if ($_POST)
- {
- $form = Arr::overwrite($form, $_POST);
- // create a kudo template
- $kudo_template = ORM::factory('kudo_template');
- $kudo_template->values(Arr::merge($form, $_FILES));
- if ($kudo_template->check())
- {
- try
- {
- $kudo_template->save();
- $this->request->redirect(URL::site('admin/kudo_templates'));
- }
- catch (Exception $e)
- {
- throw new Kohana_Exception($e->getMessage());
- }
- }
- else
- {
- $errors = $kudo_template->validate()->errors('kudo_template');
- }
- }
- // get kudo categories for form dropdown
- $kudo_categories = ORM::factory('kudo_category')->order_by('name', 'ASC')->find_all();
- $this->template->title[] = 'New Kudo Template';
- $this->template->content = View::factory('admin/kudo_templates/new')
- ->set('form', $form)
- ->set('kudo_categories', $kudo_categories)
- ->set('errors', isset($errors) ? $errors : array());
- }
Add Comment
Please, Sign In to add comment