Hi, I have form:
<form action="{{ url('users') }}" method="POST">
<table>
<tr><td><label for="login">user:</label></td><td><input type="text" name="login" value=""></td></tr>
<tr><td><label for="password">password:</label></td><td><input type="password" name ="password"></td></tr>
<tr><td><label for="email">email:</label></td><td><input type="text" name ="email"></td></tr>
<tr><td colspan="2"><input type="submit" value="add"></td></tr>
</table>
{{Form::token()}}
</form>
and one route:
Route::controller('/users','UsersController');
if form validation is failed shows a message and I would like to forward the data form in views like this:
public function postIndex(){
$data = Input::all();
//walidacja formularza
return View::make('users/create')->with('user',$data)->withErrors($validator);
}
{{ isset ($user) ? $user['login']:''}}
how to do it differently? (with using controller route-> Route::controller('/users','UsersController'); )
Thanks for your help ;)
First of all I'd recommend you to use Blade templating for the form Laravel docs
If I understand you correctly, you want this:
{{ $errors->first('login') }}
Or if you want to style it inside a tag, pass in a second parameter as this:
{{ $errors->first('login', '<span class="error">:message</span>') }}
It should be placed inside the form
And perhaps it would be better to return
return Redirect::back()->withInput()->withErrors($validator);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community