public function addAction() { $addForm = new Vendor_Forms_VendorSave(); $addForm->submit->setLabel("保存继续新建"); $addForm->submit2->setLabel("保存返回上页"); $errorMsg = null; $vendors = new Vendor_Models_VendorMapper(); $vtypes = new General_Models_VtypeMapper(); $vtypes->populateDd($addForm); $addForm = $vendors->formValidator($addForm,0); if($this->getRequest()->isPost()) { $btClicked = $this->getRequest()->getPost('submit'); $formData = $this->getRequest()->getPost(); if($addForm->isValid($formData)) { $array = $vendors->dataValidator($formData,0); $trigger = $array['trigger']; $errorMsg = $array['errorMsg']; if($trigger == 0) { $userId = $this->getUserId(); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($userId); $vendor = new Vendor_Models_Vendor(); $vendor->setName($addForm->getValue('name')); $vendor->setContact($addForm->getValue('contact')); $vendor->setTypeId($addForm->getValue('typeId')); $vendor->setBusiField($addForm->getValue('busiField')); $vendor->setPhoneNo($addForm->getValue('phoneNo')); $vendor->setOtherContact($addForm->getValue('otherContact')); $vendor->setAddress($addForm->getValue('address')); $vendor->setRemark($addForm->getValue('remark')); $vendor->setContactId($contactId); $vendors->save($vendor); $errorMsg = General_Models_Text::$text_save_success; $addForm->reset(); if($btClicked=="保存返回上页") { $this->_helper->flashMessenger->addMessage('对供应商:'.$vendor->getName().'的新建成功。'); $this->_redirect('/vendor'); } } else { $addForm->populate($formData); } } else { $addForm->populate($formData); } } $this->view->errorMsg = $errorMsg; $this->view->addForm = $addForm; }