问题
I am having trouble to set the laravel checkbox selected in edit mode. So, I do the testing with clean install of latest version of laravel and created a MySQL table named "checkbox" which contains 2 columns. One is id
and the other one is mycheckbox
.
Here is my code:
Route::get('/checkbox', function(){
$data = DB::table('checkbox')->where('id', '1')->first();
var_dump($data);
echo Form::model($data);
echo Form::checkbox('mycheckbox', '1',true);
echo Form::close();
});
I found out that no matter what I set the checkbox to be checked or not on the checkbox helper, it will always follow the data from database.
How can I solve it?
Thank you.
来源:https://stackoverflow.com/questions/25800265/unable-to-set-laravel-checkbox-selected-in-edit-mode