douxunwei8259 2014-11-11 16:10
浏览 144
已采纳

Laravel - 重新填充复选框以勾选或未勾选

In Laravel, if validation failed, it goes back to a same form page. How to repopulate a checkbox to ticked or unticked?

By default, it should be unticked when loading on the page for the first time.

{{ Form::checkbox('custom_address', false, 
   Input::old('custom_address'), array('class' => 'test')); }}
  • 写回答

2条回答 默认 最新

  • doudie2693 2014-11-11 16:22
    关注

    You need to set a value for your checkbox, otherwise the Input class will always have it empty / unchecked.

    Give the checkbox a value of 1, then it should work.

    {{ Form::checkbox('custom_address', 1, Input::old('custom_address'), array('class' => 'test')); }}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?