I didn't understand the documentations and examples I've found around about populating a form with Form::model()
and updating the data.
First, the form is not being populated with it.
{!! Form::model($post, ['route' => ['/admin/post/edit', $post->id]]) !!}
...
{!! Form::close() !!}
The Controller:
public function edit($id)
{
return \View::make('admin/post/edit')->with([
'post' => \DB::table('posts')->find($id)
]);
}
The route:
Route::get('/admin/post/edit/{id}', [
'as' => '/admin/post/edit',
'uses' => 'Admin\PostController@edit'
]);
According to what I've seen, the form was supposed to be filled with the selected data automagically, but that's not the case with me. I tested the $post
variable with {{ var_dump($post) }}
and it printed the information from the database, which means it's returned, but why isn't the form filled?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire