/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('NameIsRequired')); $this->frm->getField('video')->isFilled(BL::err('FieldIsRequired')); // no errors? if ($this->frm->isCorrect()) { // build video record to insert $item['product_id'] = $this->product['id']; $item['title'] = $this->frm->getField('title')->getValue(); $item['embedded_url'] = $this->frm->getField('video')->getValue(); $item['sequence'] = BackendCatalogModel::getMaximumVideosSequence($item['product_id']) + 1; // save the item $item['id'] = BackendCatalogModel::saveVideo($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_video', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('media') . '&product_id=' . $item['product_id'] . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id'] . '#tabVideos'); } } }