Reputation: 2087
just wondering how edit details once you've saved them onto your database?
Like I want to edit Name and Contact details from the browser?
So far I have placeholders or stuff that I want to edit.
<ul class="no-bullet">
<li>Full Name: {{ $providerName }} {{ $providerSurname }}</li>
<li>Email Adress: {{ $providerEmail }}</li>
<li>Contact Number:</li>
<li>Company:</li>
</ul>
<a href="#" class="small radius button">Edit Details</a>
Upvotes: 0
Views: 3147
Reputation: 2087
{{ Form::model($provider, array('route' => array('provider.update', $provider->id))) }}
using the code above it doesn't autofill the fields in my edit form. However when I removed the first array like this the form has filled with data.
{{ Form::model($provider, array('provider.update', $provider->id)) }}
Upvotes: 1
Reputation: 87719
You can bind a database model to your form:
Form::model($provider, array('route' => array('provider.update', $user->id)))
Laravel will automagically fill out your inputs with database data.
This this is could be your accountEdit
view:
<html>
<head>
<title></title>
</head>
<body>
{{ Form::model($provider, array('route' => array('provider.update', $provider->id))) }}
{{ Form::label('providerName', 'Full Name:')) }}
{{ Form::text('providerName') }}
{{ Form::text('providerSurname') }}
{{ Form::label('providerEmail', 'E-Mail Address') }}
{{ Form::text('providerEmail') }}
{{ Form::submit('Send this form!') }}
{{ Form::close() }}
</body>
</html>
This could be your route
Route::get('edit', function() {
$provider = Provider::find(1);
return View::make('accountEdit')->with(compact('provider'));
});
Route::get('provider/update', array('as'=>'provider.update', function() {
dd(Input::all())
});
Upvotes: 3