I'm on a "blade" page that have:
<a
type="button"
data-passage="{{$passage}}"
class="btn btn-warning btn-xs editPassageButton"
data-toggle="modal"
data-target="#editPassage">Edit</a>
Then a modal like:
<div class="modal fade" id="editPassage"
tabindex="-1" role="dialog"
aria-labelledby="favoritesModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title"
id="addPassageLabel">Modifica Brano</h4>
</div>
<div class="modal-body">
@php
$passage = "?????????";
@endphp
{{ Form::model($passage, array('route' => array('passage.update', 'null'), 'method' => 'POST')) }}
etc. etc.
Then a script part like this:
$(function() {
$('.editPassageButton').on("click", function (e) {
passage = $(this).data('passage');
});
});
And it works properly, so I cannot well understand how to send it to the php variable on the modal (the part with ???????). I found several post that suggest to send it trough a form, but it seem tricky to me, and for Laravel how it works? do i need to add a route in that case? no cleaner way to do it? I know how to pass single variable to a modal form, but i prefer to using the variable that is the model that i need to update...