Hi I'm new to Laravel and im following the laracasts on view partials and form reuse.
I am getting to an edit page fine. The html looks like this:
@extends('app')
@section('content')
<h1>Edit: {!! $edu_content->title !!} </h1>
{!! Form::model($edu_content, ['method' => 'PATCH', 'url' => 'edu_contents/' . $edu_content->id ]) !!}
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('tags', 'Tags:') !!}
{!! Form::text('tags', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('user_id', 'User ID:') !!}
{!! Form::text('user_id', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('location', 'Location:') !!}
{!! Form::text('location', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('file_size', 'File Size:') !!}
{!! Form::text('file_size', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('uploaded_at', 'Created On:') !!}
{!! Form::input('date','uploaded_at', date('Y-m-d'), ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Add Edu content!', ['class' => 'btn btn-primary form-control']) !!}
</div>
{!! Form::close() !!}
@if ($errors->any())
<ul class="alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
@stop
When I view the page source, however, it says action="http://localhost/edu_contents" rather than action="http://localhost/edu_contents/5" like it should.
Then when I submit the form to update I get:
MethodNotAllowedHttpException in RouteCollection.php line 201:
in RouteCollection.php line 201
at RouteCollection->methodNotAllowed(array('GET', 'HEAD', 'POST')) in RouteCollection.php line 188
at RouteCollection->getRouteForMethods(object(Request), array('GET', 'HEAD', 'POST')) in RouteCollection.php line 140
at RouteCollection->match(object(Request)) in Router.php line 744
at Router->findRoute(object(Request)) in Router.php line 653
at Router->dispatchToRoute(object(Request)) in Router.php line 629
at Router->dispatch(object(Request)) in Kernel.php line 229
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
Can anyone explain the error and why the id does not show up in the action?
My routes looks like Route::resource('edu_contents','EduContentsController');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire