0
index.blade.php
<table>
@foreach($masters as $master)
<tr>
<td>{{$master->receive_email_neworder_masters}}</td>
<td>
<button
class="btn btn-info"
data-my_table = "masters"
data-myVar = "{{$master->receive_email_neworder_masters}}"
data-toggle="modal"
data-target="#edit">Edit
</button>
</td>
</tr>
@endforeach
</table>
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="box box-primary box-header with-border">
<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="myModalLabel">Edit </h4>
</div>
<form action="{{route('masters.update', 'test')}}" method="post">
{{method_field('patch')}}
{{csrf_field()}}
<div class="modal-body">
@include('masters.form_edit')
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$('#edit').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget); {
var myVar = button.data('myVar');
var modal = $(this);
modal.find('.modal-body #strVar').val(myVar);
}
}
</script>
form.blade.php
<div class="input-group">
<input name="checkbox"
id="idvar"
type="checkbox"
checked="strVar"> <!-- Quero usar aqui -->
<label>
I will desire receive email when insert new order.
</label>
<br />
</div>
Inside the checkbox I want to check according to the value of myVar (Yes or No), the value that is in the field and already confirmed via Alert(strVar) is set to No but is working inside the checkbox. The foreach makes a list and for each record I select a variable and put inside the button, then in the script I take the value and Seto for a variable that will be used inside a modal with a form. Everything works well for other purposes, but within the checkbox I can not make work and do not know access to variable.
Simply put, it would be something to work with:
'id_buildings é uma variavel setada dentro do script e funciona bem aqui no input'
<label>Buindings</label>
<input type="text" class="form-control" name="id_buildings" readonly="readonly" id="id_buildings">
<script>
$('#edit').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var id_buildings = button.data('my_id_buildings');
var modal = $(this);
modal.find('.modal-body #id_buildings').val(id_buildings);
modal.find(' ').val(id_buildings);
}
</script>
'id_building não funciona aqui porque ela não é um tipo php'
{!! Form::select('id_buildings', $buildings, null ) !!
Thank you guys for any kind of help!
Try to explain your doubt better, keep in mind that we do not know how its interface, or anything else.
– Jedson Melo
Yes, I’ll change the question! Thank you!
– Emilio Dami Silva