本文整理匯總了PHP中Illuminate\Session\SessionManager::hasOldInput方法的典型用法代碼示例。如果您正苦於以下問題:PHP SessionManager::hasOldInput方法的具體用法?PHP SessionManager::hasOldInput怎麽用?PHP SessionManager::hasOldInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Session\SessionManager
的用法示例。
在下文中一共展示了SessionManager::hasOldInput方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preSet
public function preSet(FormEvent $event)
{
$form = $event->getForm();
$rootName = $form->getRoot()->getName();
if (!$form->isRoot() && ($parent = $form->getParent())) {
$name = $this->getDottedName($form);
$fullName = $this->getFullName($rootName, $name);
// Add input from the previous submit
if ($form->getName() !== '_token' && $this->session->hasOldInput($fullName)) {
// Get old value
$value = $this->session->getOldInput($fullName);
// Transform back to good data
$value = $this->transformValue($event, $value);
// Store on the form
$event->setData($value);
}
if ($this->session->has('errors')) {
/** @var \Illuminate\Support\ViewErrorBag $errors */
$errors = $this->session->get('errors');
if ($errors->has($name)) {
$form->addError(new FormError(implode(' ', $errors->get($name))));
}
}
}
}
示例2: edit
/**
* Shows the form for item editing.
*
* @param string $model Model to use.
* @param int $id Item ID.
* @return \Illuminate\Http\Response
*/
public function edit($model, $id)
{
$this->setModel($model);
$this->checkAction('edit');
$item = $this->staticModelgetFormItem($id);
if (!$item) {
abort(404);
}
$title = trans('lavanda::common.edit_title', ['entity' => mb_strtolower($this->staticModelGetName()), 'id' => $id]);
$form = $this->staticModelGetForm('put', $this->getRoute('update', ['id' => $id]), $this->session->hasOldInput() ? null : $item);
if (!$this->session->has('back_url')) {
$this->session->flash('back_url', $this->request->server('HTTP_REFERER'));
} else {
$this->session->reflash();
}
return view('lavanda::entity.edit', ['title' => $title, 'form' => $form]);
}