Home  >  Q&A  >  body text

When using laravel, the problem of saving checkboxes to the database

When using laravel, there is a problem with saving check boxes to the database. This is the demo of html:
https://jsfiddle.net/4j3hoyvn/

Question:
How to save the checkbox in the form in the database? Create a separate table?

The effect to be achieved:
When the "Edit Page" is opened, the check box items selected when creating must be selected. I know how to do radio buttons and other types, but I don't know how to do check boxes.

滿天的星座滿天的星座2712 days ago472

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-16 16:53:04

    1. If you are using laravel’s FROMS library, you can judge by blade’s @if and then use it

    Form::checkbox('name', 'value', true);

    To generate the selected state of the check box;


    2. Of course, you can also use js (such as jq) to change the checked status of the checkbox based on the value


    3. You can also use vuejs or Angola’s data binding to change the checked status of the check box
    Vuejs case

    reply
    0
  • Cancelreply