public function addAction() { $form = new Jameen_Admin_Forms_Followup(); $followup = new Jameen_Followupemails($this->getRequest()->getParam('id')); $form->addElement('hidden', 'id', array('value' => $followup->id)); if ($followup->id) { $form->contact_group_id->setValue($followup->contact_group_id); $form->day->setValue($followup->day); $form->subject->setValue($followup->subject); $form->email_body_html->setValue($followup->email_body_html); } if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { //write code to save into databse $followup->contact_group_id = $formData['contact_group_id']; $followup->day = $formData['day']; $followup->subject = $formData['subject']; $followup->email_body_html = $formData['email_body_html']; $id = $followup->save(); $message = new Jameen_Alerts_Internal('Folloup saved successfully', 'success', 'followup', 'index', 'admin'); $this->_redirect("/admin/followup"); } else { $form->populate($formData); } } $this->view->errors = array(); foreach ($form->getMessages() as $field => $msgs) { foreach ($msgs as $msg) { $this->view->errors[$field] = $msg; break; } } $this->view->form = $form; }
public static function factory($id) { if (isset($instance)) { return $instance; } else { $className = __CLASS__; self::$instance = new $className($id); return self::$instance; } }