我正在与Laravel 5.2合作开展一个项目。我没有收到任何错误,我的表格也没有提交。
继承人我的表格
<form class="form-horizontal">
{!! Form::open(['method'=>'POST','action'=>'TicketsController@store','files'=>true],['class=>form-horizontal form bordered']) !!}
<div class="form-group">
{!! Form::label('problem_title','title',['class'=>'control-label col-lg-2']) !!}
<div class="col-lg-10">{!! Form::text('problem_title',null,['class'=>'form-control']) !!}</div>
</div>
<div class="form-group ">
{!! Form::label('category_id','Category:',['class'=>'control-label col-lg-2']) !!}
<div class="col-lg-10">{!! Form::select('category_id',$categories,'3',['class'=>'form-control']) !!}</div>
</div>
<div class="form-group ">
{!! Form::label('Status_id','Status:',['class'=>'control-label col-lg-2']) !!}
<div class="col-lg-10">{!! Form::select('status_id',$statuses,'3',['class'=>'form-control']) !!}</div>
</div>
<div class="form-group">
{!! Form::label('body','How can We help you?',['class'=>'control-label col-lg-2']) !!}
<div class="col-lg-10">{!! Form::text('body',null,['class'=>'form-control','rows'=>5 ,'cols'=>5]) !!}</div>
</div>
<div class="form-group">
{!! Form::label('photo_id','ScreenShot:',['class'=>'control-label col-lg-2']) !!}
<div class="col-lg-10">{!! Form::file('photo_id', ['class'=>'form-control']) !!}</div>
</div>
<div class="text-right">
{!! Form::submit('Create Ticket',['class'=>'btn btn-primary ']) !!}
</div>
</form>
这也是我的控制器来创建和存储表单。
public function create()
{
$categories=Category::lists('name','id')->all();
$statuses=Status::lists('name','id')->all();
return view('tickets.create', compact('categories','statuses','users'));
}
public function store(Request $request)
{
{
$user=Auth::user();
$input = $request->all();
if($file=$request->file('photo_id')){
$name=time() . $file->getClientOriginalName();
$file-> move('images',$name);
$photo=Photo::create(['file'=>$name]);
$input['photo_id']=$photo->id;
}
$user->ticket()->create($input);
/*Post::create($input);*/
return redirect('tickets');
}
}
我做错了什么?我提交表单后,我会在URL中收到此信息。小心帮忙,我的时间不多了。
http://www.projecty.com/tickets/create?_token=eXQHc1FS8mObR4lbyqxvXlASyZfZNidVgnjacaSb&_token=eXQHc1FS8mObR4lbyqxvXlASyZfZNidVgnjacaSb&problem_title=chuu&category_id=2&status_id=1&body=h7ju87&photo_id=house.jpg
答案 0 :(得分:1)
我没有更多关于laravel的经验,但是在第二行你写了['class=>form-horizontal form bordered']
以及其他任何地方['class'=>'form-control']
。做错误报告并调试你的代码哪一行有麻烦。