How to get the values for a series of checkboxes in Laravel 4 controller (if checked)

后端 未结 3 991
既然无缘
既然无缘 2020-12-31 11:56

I would like to get the values for a series of checkboxes I have set up in a Laravel 4 form. Here is the code in the view setting up the checkboxes:

@foreac         


        
3条回答
  •  清歌不尽
    2020-12-31 12:10

    If checkboxes are related then you should use [] in the name attribute.

    @foreach ($friends as $friend)
    
    @endforeach
    
    
    $friends_checked = Input::get('friend');
    if(is_array($friends_checked))
    {
       // do stuff with checked friends
    }
    

提交回复
热议问题