Vin*_*nce 2 checkbox formbuilder laravel
我正在使用Laravel的表单构建器来生成登录表单.这看起来很简单,但它不起作用.我正在尝试为我的复选框创建一个标签,可以单击该标签来设置/取消设置复选框.目前,单击标签不会执行任何操作.这是我的代码:
{{ Form::open(array('url' => '/account/login', 'role' => 'form')) }}
{{ Form::token() }}
<div class="form-group">
{{ Form::label('email', 'Email Address', array('class' => 'sr-only')) }}
{{ Form::text('email', '', array('class' => 'form-control', 'placeholder' => 'Email Address')) }}
</div>
<div class="form-group">
{{ Form::label('password', 'Password', array('class' => 'sr-only')) }}
{{ Form::password('password', array('class' => 'form-control', 'placeholder' => 'Password')) }}
</div>
{{ Form::submit('Login', array('class' => 'btn btn-default')) }}
<a href="#forgotpassword" class="btn btn-link btn-sm pull-right">Forgot password?</button></a><br>
{{ Form::checkbox('remember') }}
{{ Form::label('remember', 'Remember me') }}
{{ Form:: close() }}
Run Code Online (Sandbox Code Playgroud)
我不确定问题是什么,但我可能错过了一些明显的问题.任何帮助是极大的赞赏!
我相信标签元素链接到id属性而不是name属性.(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label)您需要创建一个ìd表单复选框元素.
你可以尝试类似的东西
{{ Form::checkbox('remember', 1, null, ['id'=>'remember', 'class' => 'className']) }}
这应该工作.
| 归档时间: |
|
| 查看次数: |
4010 次 |
| 最近记录: |