lundi 2 novembre 2020

Input checkbox with multiple value on laravel

I'm making input using the checkbox, only hardware table need to input multiple checkbox values When im trying using implode, i got appear errorException: "implode(): Invalid arguments passed".

Here my controller code :

auth()->user()->Form()->create
([
    'user_id' => $request->user_id,
    'os' => $request->os,

    'hardware' => implode(',', $request->input('hardware')),
    // $arrayToString = implode(',', $request->input('hardware'));

    'software' => $request->software,
    'signature' => $signature,
    'status_desc' => $request->status_desc,
    'cancel_deskripsi' => $request->cancel_deskripsi
]);


dd($form);
return redirect()->route('form')->with('status', 'success');

My view code:

<div class="form-group col-md-12">
<label>Hardware :</label>
<div class="checkbox-list">
    <label class="form-group col-md-4">
        <input type="checkbox" id="hardware" name="hardware[]" value="Komputer AIO">
        <span></span>
        Komputer AIO
    </label>
    <label class="form-group col-md-4">
        <input type="checkbox" class="form-group" id="hardware" name="hardware" value="Laptop">
        <span></span>
        Laptop
    </label>
    <input id="other" name="how" type="checkbox" class="form-group">
    <label for="other" class="form-group">Other :</label>
    <div class="other-disclosure">
        <input type="text" name="hardware" id="os-other" class="form-group col-md-2" placeholder="...">
    </div>
</div>

How to solve this problem ?




Aucun commentaire:

Enregistrer un commentaire