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