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