public static function factory($id) { if (isset($instance)) { return $instance; } else { $className = __CLASS__; self::$instance = new $className($id); return self::$instance; } }
public function aminitiesAction() { $form = new Jameen_Admin_Forms_PropertyAminities(); $aminities = new Jameen_Aminities($this->getRequest()->getParam('id')); $form->addElement('hidden', 'id', array('value' => $aminities->id)); $go = $this->getRequest()->getParam('id'); if ($aminities->id) { $this->getRequest()->getParam('id')->setValue($aminities->listing_id); $form->amenitie_id->setValue($aminities->amenitie_id); } if ($this->_request->isPost()) { $formData = $this->_request->getPost(); print_r($go); //die; if ($form->isValid($formData)) { //write code to save into databse $go = $formData['listing_id']; $aminities->amenitie_id = $formData['amenitie_id']; $id = $aminities->save(); $message = new Jameen_Alerts_Internal('Aminities saved successfully', 'success', 'listings', 'index', 'admin'); $this->_redirect("/admin/listings"); } else { echo 'go'; $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; }