简体   繁体   中英

I cant store checkbox value into session

I am trying to put a checkbox value into a session. When I am trying to save it in Laravel, it saves the name field of the checkbox like foo[].

<ul class="check-square">
    <?php Session::put('selectsubservice', 'selectsubservice[]'); ?> @foreach($subservices as $subservice)
        <li><input type="checkbox" name="selectsubservice[]" value="{{$subservice->id}}">{{$subservice->name}}</li>
    @endforeach
</ul> 

Session::put('selectsubservice', $subservice->id);

You are passing the name of the input field as the argument to Session::put, that will not be automatically substituted. You need to pass the actual value to Session::put.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM