public function createAction() { $form = new Slide_Form(); $form->removeElement('image_preview'); $form->removeElement('image'); $form->removeElement('caption'); if ($form->isValid($_POST)) { $values = $form->getValues(); $mdlSlide = new Slideshow_Slide(); $slide = $mdlSlide->createSlide($values['show_id'], $values['title']); $this->_request->setParam('id', $slide->id); $this->_request->setParam('isInsert', true); $this->_forward('edit'); } else { $showId = $_POST['show_id']; if ($showId > 0) { $this->_request->setParam('id', $showId); $this->_forward('edit', 'show'); } else { $this->_forward('index', 'index'); } } }
public function editAction() { $form = new Show_Form(); $mdlShow = new Slideshow_Show(); if ($this->_request->isPost() && $form->isValid($_POST) && $this->_request->getParam('isInsert') != true) { $values = $form->getValues(); $results = $mdlShow->updateShow($values['id'], $values['name'], $values['description']); $show = $results->page; } else { $id = $this->_request->getParam('id'); $show = $mdlShow->find($id)->current(); $form->populate($show->toArray()); } $form->setAction($this->baseUrl . '/mod_slideshow/show/edit'); $submit = $form->getElement('submit'); $submit->setLabel($this->view->getTranslation('Update Slideshow')); $this->view->form = $form; $this->view->show = $show; $mdlSlide = new Slideshow_Slide(); $this->view->slides = $mdlSlide->getSlides($show->id); $slideForm = new Slide_Form(); $slideForm->removeElement('image'); $slideForm->removeElement('imagepath'); $slideForm->removeElement('previewpath'); $slideForm->removeElement('image_preview'); $slideForm->removeElement('caption'); $slideFormValues['show_id'] = $show->id; $slideForm->populate($slideFormValues); $slideForm->setAction($this->baseUrl . '/mod_slideshow/slide/create'); $submit = $slideForm->getElement('submit'); $submit->setLabel($this->view->getTranslation('Add New Slide')); $this->view->slideForm = $slideForm; $this->view->breadcrumbs[$show->name] = $this->baseUrl . '/mod_slideshow/show/edit/id/' . $show->id; $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark/url/mod_slideshow/show/edit/id/' . $show->id; $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/mod_slideshow/show/delete/id/' . $show->id; }