0

I'm trying to check the checkboxes on my edit view fetching the data from a table so the problem is all the checkboxes come unchecked. heres the code:

i don't know if this helps but in the table the data stores in an array there's not pivot table so i'm really trying to do it without using or making a pivot tablet.

        <div class="form-group" style="padding-left: 1.4%">
        {!!Form::label('estudio[]', 'Estudios Realizados* : ')!!}<br>
        @foreach ($estudio as $key => $value)
        @if(in_array($key, $my_estudio))
            <input class="lista-estudio" name="estudio[]" type="checkbox" value="{{$key}}" id="estudio[]" checked> {{$value}}
        @else
            <input class="lista-estudio" name="estudio[]" type="checkbox" value="{{$key}}" id="estudio[]">{{$value}}
        @endif
        @endforeach
    </div>
  • Can you show values of `$estudio` and `$my_estudio`? It's hard to say without knowing those values – ljubadr Jan 17 '19 at 02:50
  • Well `$estudio` is the variable im using for bring the data of my estudio table the data should be all the ids on my table and the names heres how i create the estudio variable and `$my_estudio` variable: `pluck('estudio', 'id'); $salarios = Salario::all()->pluck('monto', 'id'); $my_estudio = $model->estudio; $my_colores = $model->color; ?>` – Victor Diaz Jan 17 '19 at 14:19
  • `$model` variable is an instance of my model compra, so it's to fetch all the data from my table compra when im editing a row. – Victor Diaz Jan 17 '19 at 14:26

0 Answers0