Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
656 views
in Technique[技术] by (71.8m points)

checkbox - How to handle unchecked checkboxes in Laravel?

I have an edit form with several checkboxes in Laravel. When I check the boxes and update the record, it works correctly, but if I uncheck the box it doesn't return any value so the record doesn't update and the value remains true in the database.

How can I handle unchecked checkboxes in Laravel?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Place a hidden textbox with a 0 value before the checkbox so a 0 value is sent into the POST array.

{{Form::hidden('value',0)}}
{{Form::checkbox('value')}}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...