Laravel : Form and fetch the ID

Asked

Viewed 33 times

-2

Is there any way to fetch the ID (to store in the BD) and the name for the user to select ?

    <option selected>Escolher Capitulo</option>

    @foreach($capitulos as $cap)
      <option class="form-control" id="id_capitulo" name="id_capitulo"> 
        {{$cap->capitulo}}
      </option>
    @endforeach 
</select>

Thank you!

2 answers

0


I don’t know if I understand the question very well, but I’ll try anyway. Would you like to send the chapter ID to the controller and in the view show the chapter name? In this case just put the id in the option value:

<option class="form-control" id="id_capitulo" value="{{$cap->id}}" name="id_capitulo"> {{$cap->capitulo}}</option>

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.