adhik13th
3 months ago
523
7
Laravel

Laravel can't pass ID on modal input

Posted 3 months ago by adhik13th

So iam using bulma for my modal input and i have problem in my input always get 404 . and this problem is this id cant stored on this form . you can see this form like this and i dont know where my fault

1.Table

  @foreach ($data as $i)
    <tr>
       <td>{{ $i->turunan_anak->uraian}}</td>
       <td>16</td>
       <td>46</td>
       <td>{{$i->kode_rekening}}</td>
       <td>{{$i->uraian}}</td>
       @if(empty($i->user_id))
       <td>belum dipilih</td>
       @else()
       <td>   $i->users->nama_unit</td>
        @endif
       
       <td> 
        <a class = "button is-danger modal-button" id="lanuchModal"
                  data-id="{{$i->id}}"
                  data-user_id="{{$i->user_id}}"
                  data-target="#modal"
                  >Pilih Pelaksana</a> 
       </td> 
       @endforeach

2.Modal

         <form  action="{{route('store_id'),'test'}} " method="post">
                  @csrf
                  {{method_field('patch')}}
                <div id="modal" class="modal">
                  <div class="modal-background"></div>
                  <div class="modal-card">
                    <header class="modal-card-head">
                      <p class="modal-card-title">Pilih Pelaksana</p>
                      <button class="delete" id="modal-close" aria-label="close"></button>
                    </header>
                    <section class="modal-card-body">
                        <div class="field">
                            <div class="control">                      
                          
                              <div class="select is-medium is-danger"> 
                                <select id="user_id" name="user_id">
                                  @foreach($pelaksana as $id => $nama )
                                  <option value="{{ $id }}">{{ $nama }}</option>
                                  @endforeach
                                </select>
                              </div>
                              <input type="hidden" name="id" id="id" value="">
                            </div>
                          </div>
                    </section>
                    <footer class="modal-card-foot">
                      <button type="submit" class="button is-success">Save changes</button>
                    </footer>
                  </div>
                </div>
              </form>
  1. My Js for modal

     <script>
     $('.modal').on('show.bs.modal', function (event) {
    
         var button = $(event.relatedTarget) // Button that triggered the modal
         var id           = button.data('id')
         var user_id      = button.data('user_id')
         var modal = $(this)
    
         modal.find('.modal-card-body #id').val(id);
         modal.find('.modal-card-body #user_id').val(user_id);
     })
      </script>
    
  2. and last its my die dump

array:4 [▼
  "_token" => "KV5anuTdRXWt3RKHtFMzgud6DN69PzXQX0Pj9ire"
  "_method" => "patch"
  "user_id" => "3"
  "id" => null
]

this id always null i dont know what happen , anyone have solution ?

Please sign in or create an account to participate in this conversation.