本文整理匯總了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);
}
}