當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helper::parsFormInvalidMessages方法代碼示例

本文整理匯總了PHP中Library\Utility\Helper::parsFormInvalidMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helper::parsFormInvalidMessages方法的具體用法?PHP Helper::parsFormInvalidMessages怎麽用?PHP Helper::parsFormInvalidMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Library\Utility\Helper的用法示例。


在下文中一共展示了Helper::parsFormInvalidMessages方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     try {
         /**
          * @var \DDD\Service\Apartel\Type $typeService
          * @var Request $request
          */
         $typeId = $this->params()->fromRoute('type_id', 0);
         $typeService = $this->getServiceLocator()->get('service_apartel_type');
         $typesRates = $typeService->getApartelTypesWithRates($this->apartelId, true);
         $request = $this->getRequest();
         // set Type From
         $typeDetails = $typeService->getTypeDetails($this->apartelId, $typeId);
         $form = new TypeForm($typeDetails['all_apartment_list']);
         $form->prepare();
         // edit mode
         if ($typeId) {
             $form->populateValues($typeDetails);
         }
         // submit data
         if ($request->isPost()) {
             $form->setInputFilter(new TypeFilter());
             $filter = $form->getInputFilter();
             $form->setInputFilter($filter);
             $data = $request->getPost();
             $form->setData($data);
             if ($form->isValid()) {
                 $vData = $form->getData();
                 $flash = ['success' => $typeId ? TextConstants::SUCCESS_UPDATE : TextConstants::SUCCESS_ADD];
                 $responseTypeId = $typeService->saveType($vData, $this->apartelId);
                 Helper::setFlashMessage($flash);
                 return $this->redirect()->toRoute('apartel/type-rate/type', ['type_id' => $responseTypeId, 'apartel_id' => $this->apartelId], [], true);
             } else {
                 $messages = Helper::parsFormInvalidMessages($form->getMessages());
                 $flash = ['error' => $messages];
                 Helper::setFlashMessage($flash);
             }
         }
         return ['typeRates' => $typesRates, 'form' => $form, 'typeId' => $typeId];
     } catch (\Exception $e) {
         Helper::setFlashMessage(['error' => TextConstants::ERROR]);
         return $this->redirect()->toRoute('apartel/type-rate/home', ['apartel_id' => $this->apartelId], [], true);
     }
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:44,代碼來源:TypeRate.php


注:本文中的Library\Utility\Helper::parsFormInvalidMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。