mardi 16 juin 2020

checkbox array recovering old values checked

I would like to retrieve old values in my add form and at the same time recovering data in the edit page stored previously in the database.

here is my code:

<div class="row checkbox-offres">
      <legend class="fieldset-label">Skills&nbsp;:</legend>
      @foreach ($skills as $skill)
      <div class="form-group-lg col-lg-6">
        <label>
          <input class="form-check-input @error('skills') is-invalid @enderror" type="checkbox"
            name="skills[]" value='' @foreach($demande->skills as $skill_chosen)
          
          @endforeach
          > </label>
      </div>
      @endforeach
      @error('skills')
      <div class="invalid-feedback d-block">
        
      </div>
      @enderror
    </div>

this code doesn't recovers old values in the add form and doesen't recovers data stored in databse. but recover old in the edit id someone mistake a field it's weird.

 

it's retrieve data form database but i don't konw how to put that in the condition.

by the way : Demande and Student = has many and Skills = many to many. the 3 Tables are in a classic relation ship




Aucun commentaire:

Enregistrer un commentaire