我想从数据库设置复选框状态,所以我写,
I want to set check-boxes state from database, so I write,
{{ Form::checkbox('asap', null, $offer->asap) }}
但是如果我想将'id'设置为复选框
But if I want to set 'id' to the check-box like
{{ Form::checkbox('asap', null, $offer->ASAP, array('id'=>'asap')) }}
它总是将我的复选框状态设置为 true.(在用户选择之前)
It always set my check-box state to true. (Before user select it)
那么在用户选择之前设置复选框状态时,如何在刀片复选框中设置id"?
So question how set 'id' in blade check-boxes when check-box state is set before user select it?
第三个参数决定是否选中复选框.所以可能 $offer->ASAP
(或 $offer->asap
为真(或不假或不为空).如果你想取消选中复选框将其设置为 false,或者不使用第三个参数(设置为 null 或 false):
3rd argument decides whether checkbox is checked or not. So probably $offer->ASAP
(or $offer->asap
is true (or not false or not null). If you want to to make checkbox unchecked either set it to false, or don't use 3rd argument (set to to null or false):
{{ Form::checkbox('asap',null,null, array('id'=>'asap')) }}
编辑
另一种可能性是您的页面上有一些自定义 JavaScript 代码,这些代码通过 asap
id 查找元素并选中此复选框.所以当你不设置id时,JavaScript是无法勾选的,但是当你设置了这个id时,复选框会被JavaScript勾选.
Another possibility is that you have on your page some custom JavaScript code that finds element by asap
id and checks this checkbox. So when you don't set id, JavaScript cannot check it, but when you set this id, the checkbox will be checked by JavaScript.
这篇关于Laravel 刀片复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!