Dears,
I am trying to pass a column value in a row to a modal when I click on edit, but that is not working. I am not sure how to do that honestly. When I click on edit, a modal should open. My goal is to display the current image name in a disabled field and let the admin enter the new name to rename it.
My admin template source => https://startbootstrap.com/theme/sb-admin-2
datatable code :
<tbody>
    <?php
        foreach ($imagesPath as $imageId=>$imagePath) {
            echo "<tr>";
                echo "  <td> <img src=".$imagePath." border='0' height=200px width=200px /> </td>";
                echo "  <td name='imageName'>".substr($imagePath, 59)."</td>";
                echo "  <td>
                            <a href='#' class='btn btn-info btn-circle' data-toggle='modal' data-target='#editModal' data-val=".$imagesPath[$imageId].">
                                <i class='fas fa-edit'></i>
                            </a>
                            <a href='#' class='btn btn-danger btn-circle'>
                                <i class='fas fa-trash'></i>
                            </a>
                        </td>";
            echo "</tr>";
        }
    ?>
</tbody>
Modal Code:
<!-- Edit Modal-->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="renameModal"
aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="renameModal">Rename Image</h5>
                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <label class="control-label" for="oldImageName">Old Image Name</label>
                <input id="oldImageName" class="form-control form-control-user" disabled></input><br>
                <label class="control-label" for="newImageName">New Image Name</label>
                <input id="newImageName" class="form-control form-control-user" type="text" ></input>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                <a class="btn btn-primary" href="#">Rename</a>
            </div>
        </div>
    </div>
</div>
js code:
<script>
    $('#editModal').on('show.bs.modal', function(e) {
        var oldImageValue = $(event.relatedTarget).data('val');
        $(e.currentTarget).find('input[id="oldImageName"]').val(oldImageValue);
    });
</script>
What I tried to implement is a solution mentioned in Passing data to a bootstrap modal . But it did not work. Can you please assist with the above?
 
    