通过表格指导

时间:2015-01-26 11:48:17

标签: php laravel

我是laravel的初学者。我跟着laracasts教程,我卡在你通过以下方式访问另一个页面的部分:

{{ Form::open(['url' => 'created']) }}
例如,

。 现在,这引导我到正确的网址,但它给了我 糟糕,看起来出了问题。

只要我手动输入链接,它就能正常工作。

这是它指向的页面代码:

控制器:

public function created()
{
    return 'hello';
}

路线:

Route::get('created', 'TestController@created');

查看:

   @extends('layout')

    @section('content')

        <h1> Test </h1>

    @stop

这是第一页的形式:

@extends('layout')
@section('content')
        <h1>Create New User</h1>
        {{ Form::open(['url' => 'created']) }}
        <div>
            {{ Form::label('email', 'E-mail:')}}
            {{ Form::text('email')}}
        </div>


        <div>
            {{ Form::label('password', 'Password:')}}
            {{ Form::password('password')}}
        </div>


        <div>
        {{ Form::submit('Create')}}
        </div>
        {{ Form::close()}}
@stop

这里出了什么问题?

1 个答案:

答案 0 :(得分:1)

默认打开表单链接到post方法,所以你需要的是post route或get方法。以下应该工作:

   {{ Form::open(['url' => 'created']) }}
        // Insert your fields/codes here
    {{ Form::close() }}
//Change route method to post
Route::post('created', 'TestController@created');

有关详细信息,请阅读文档here

相关问题