Unable to set Laravel checkbox selected in edit mode

旧街凉风 提交于 2019-12-11 23:02:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!