我无法提交带有laravel的表格。什么都没发生,没有显示错误。页面保持不变。
这是我的路线档案:
Route::resource('/', 'WebsiteController');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
这是具有以下形式的文件:
<div class="col-lg-12">
{!! Form::open(['url' => '/']) !!}
<div class="row">
<div class="col-md-6">
<div class="form-group wow fadeInLeft">
{!! Form::text('name',null,['class'=>'form-control','placeholder'=>'Your name *','id'=>'name']) !!}
</div>
<div class="form-group wow fadeInLeft">
{!! Form::text('email',null,['class'=>'form-control','placeholder'=>'Your email *','id'=>'email']) !!}
</div>
<div class="form-group wow fadeInLeft">
{!! Form::text('phone',null,['class'=>'form-control','placeholder'=>'Your phone *','id'=>'phone']) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group wow fadeInRight">
{!! Form::textarea('message',null,['class'=>'form-control','placeholder'=>'Your message *','id'=>'message']) !!}
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center wow bounceIn">
{!! Form::submit('Click Me!') !!}
</div>
</div>
{!! Form::close() !!}
@if ($errors->any())
<ul class='alert alert-danger' style='list-style: none;'>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
</div>
这是我的CreateContactRequest文件:
<?php namespace App\Http\Requests;
use App\Http\Requests\Request;
class CreateContactRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|min:3',
'phone' => 'required',
'email' => 'required|email',
'message' => 'required'
];
}
}
最后,这是我在WebsiteController中的商店方法:
public function store(CreateContactRequest $request)
{
$this->createContact($request);
}
在WebsiteController文件顶部包含的文件:
use App\Contact;
use App\Http\Requests;
use App\Http\Requests\CreateContactRequest;
use Illuminate\HttpResponse;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Request;
欢迎并赞赏任何帮助。