dimanche 30 août 2015

assign value to variable when clicke on button inside foreach loop in php blade template

I have been using angular js to develope web applications and i am quite fan of it. Just starting my hands on laravel 5 to learn something new. I am trying to find angular's ng-click replacement in laravel for blelow situation.

I am using simple html (no php form tags) to insert some data and display it in php blade templete using blade's @foreach control sturcture like below

<table class="table table-bordered table-striped table-hover">

          <tr>
            <th>S.No</th>
            <th>Name of value</th>
                            <th></th>
          </tr>     
          @foreach( $valuess as $index=>$value)
          <tr>
            <td>{{$index +1}}</td>
            <td>{{$value->value_name}}</td>

                            <td><button class="btn btn-success btn-sm" data-toggle="modal" data-target="#editValueModal" onclick="<?php $selectedValue = $value ?>">Edit</button></td>
          </tr> 
          @endforeach


         </table>

data is being displayed properly. As you can see on click "edit" button i open a popup . Now here the problem comes. I am trying to display the value_name in the popup whose edit button is being clicked. i tried to use html's onclick function to set a variable for the correspoiding $value object but it is always setting the last $value of loop in the variable $selectedValue.

Can some please tell me the way i can do it.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UeOHCx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire