表单提交问题
小弟是新手,最近根据教程上的指导,自己搭完一个博客网站之后,想按照自己想法修改一下。
index.blade.php代码如下:
@foreach ($articles as $article)
<div align = "center">
<h2>{{ $article->title }}</h2>
<div>{{ $article->text }}</div>
{{ Form::open(array('route' => array('articles.show', $article->id))) }}
{{ Form::submit('SHOW') }}
{{ Form::close() }}
{{ Form::open(array('method' => 'DELETE', 'route' => array('articles.destroy', $article->id))) }}
{{ Form::submit('DELETE') }}
{{ Form::close() }}
</div>
@endforeach
ArticlesController控制器中的代码如下所示:
public function show($id)
{
$article = Article::find($id);
return View::make('articles.show', compact('article'));
}
public function destroy($id)
{
Article::destroy($id);
return Redirect::route('articles.index');
}
很奇怪的是我在http://localhost:8000/articles页面,点击delete提交表单可以正常删除文章,但是点击show提交表单就出错。请各位大神指点一二,不甚感激!
index.blade.php代码如下:
@foreach ($articles as $article)
<div align = "center">
<h2>{{ $article->title }}</h2>
<div>{{ $article->text }}</div>
{{ Form::open(array('route' => array('articles.show', $article->id))) }}
{{ Form::submit('SHOW') }}
{{ Form::close() }}
{{ Form::open(array('method' => 'DELETE', 'route' => array('articles.destroy', $article->id))) }}
{{ Form::submit('DELETE') }}
{{ Form::close() }}
</div>
@endforeach
ArticlesController控制器中的代码如下所示:
public function show($id)
{
$article = Article::find($id);
return View::make('articles.show', compact('article'));
}
public function destroy($id)
{
Article::destroy($id);
return Redirect::route('articles.index');
}
很奇怪的是我在http://localhost:8000/articles页面,点击delete提交表单可以正常删除文章,但是点击show提交表单就出错。请各位大神指点一二,不甚感激!
3 个回复
吃奶的牛
赞同来自:
码农
赞同来自:
雨师
赞同来自:
或者
`// Using conventional approach
$view = View::make('greeting')->with('name', 'Steve');
// Using Magic Methods
$view = View::make('greeting')->withName('steve');`
得是有键值匹配,否则在blade里怎么读呢