我正在尝试构建一个计时器应用程序 - 这个表单应该提交时间(它确实)和客户端名称 从数据库填充,它看起来像这样: p>
{{Form :: open(array('action'=>'TasksController @ store','name'= >'计时器'))}}
{{Form :: select('client',$ client,Input :: old('client'))}}
{{Form :: hidden('duration', '',array('id'=>'val','name'=>'duration'))}}
{{Form :: submit('Submit',array('class'=>' btn btn-primary'))}}
{{Form :: close()}}
code> pre>
生成此页面的控制器如下所示: p>
public function index()
{
$ client = DB :: table('clients') - > orderBy('name','asc') - > lists('name','id');
返回View :: make('tasks.index',compact('task','client'));
}
code> pre>
我在提交表单时收到“未定义变量:客户端”。 我不明白为什么。 p>
我做错了什么? p>
编辑:我的TasksController中的商店功能如下所示: strong> p>
public function store()
{
$ input = Input :: all();
$ v = Validator :: make($ input,Task :: $ rules);
if($ v-> passes())
{
$ this-> task-> create($ 输入);
返回View :: make('tasks.index');
}
返回View :: make('tasks.index')
- > withInput()
- > withErrors( $ v)
- > with('message','有验证错误。');
}
code> pre>
div>