Skip to main content
2 of 4
added 15 characters in body
Zayn Ali
  • 4.9k
  • 1
  • 32
  • 41

Form::model basically populates the input fields with data either from old input or given model's attributes. So the basic form can be written like this.

<form action="/edit-account" method="POST">

    <input type="hidden" name="_token" value="{{ csrf_token() }}">

    <input type="hidden" name="_method" value="PUT">

    ...

</form>

And then for populating the data, you can use old helper function and then check for errors.

So a basic input block will look like this.

<input type="text" name="name" value="{{ old('name', $user->name) }}">

@if ($errors->has('name'))
    <strong>{{ $errors->first('name') }}</strong>
@endif

References:

old()

csrf_token()

Working With Error Messages

Zayn Ali
  • 4.9k
  • 1
  • 32
  • 41