dimanche 27 décembre 2015

Laravel form validation error don't show up when using with Input?

My codes for redirecting to add form when validation error occurs is as follows:

$validationArray = [ "title" => Input::get('form.' . $defLang . '.title') ] + [ "slug" => Input::get('form.page.slug') ] + [ "position" => Input::get('form.page.position') ];

$validator = $this->page->validate($validationArray);
if ($validator->fails()) {
  Session::put('flag', Input::get('form.' . $defLang . '.language_id'));

  return redirect(PREFIX . '/multicms/pages/pages/create')->withErrors($validator)->withInput();
}

when validaton error occurs,the user is redirected back to add form but without any previous inputs and error message.However,when I remove ->withInput() ,the form show validation error message.Also,when I remove ->withErrors($validator) ,the form shows previous input and obviously not the error message.This code had worked in my prevous project but not on this one.What may have gone wrong? This is really weird and eating up my head.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire