I'm trying to send the ID of a registered user to a modal for been able to edit the DB directly from the modal, but since it's a modal and not other page I can't use a routing method. And i don't know if it's possible using JavaScript
Here is my view code:
table class="highlight responsive-table">
<thead>
<tr>
<th data-field="id" hidden>ID</th>
<th data-field="name">Nombre</th>
<th data-field="last_name">Apellidos</th>
<th data-field="course">Curso</th>
<th style="text-align: right;">Acciones</th>
</tr>
</thead>
<tbody>
@foreach($professors as $professor)
<tr>
<td hidden></td>
<td></td>
<td></td>
<td></td>
<td style="text-align: right; width: 20em">
<button data-target="modalEdit" class="waves-effect waves-light btn yellow darken-2"><i class="material-icons left" style="margin:0">create</i></button>
<form method="POST" action="/professors/delete/" style="display: initial;">
<button type="submit" class="waves-effect waves-light btn red darken-1"><i class="material-icons left" style="margin:0">delete</i></button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
<!-- Modal Structure -->
<div id="modalEdit" class="modal modal-fixed-footer">
<form class="col s12" method="POST" action="/professors">
<div class="modal-content">
<h4>Editar a </h4>
<div class="row">
<div class="input-field col s6">
<input id="name" name="name" type="text" class="validate" required>
<label for="first_name">Nombre</label>
</div>
<div class="input-field col s6">
<input id="last_name" name="last_name" type="text" class="validate" required>
<label for="last_name">Apellidos</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="course" name="course" type="text" class="validate" required>
<label for="course">Nombre de curso</label>
</div>
</div>
<div class="file-field input-field">
<div class="btn btn yellow darken-2">
<span>Subir foto</span>
<input type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
<p>Nota: Porás actualizar la foto usando el botón editar.</p>
</div>
<div class="modal-footer">
<button type="submit" class="waves-effect waves-light btn blue darken-2 ">Registrar</button>
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">Cerrar</a>
</div>
</form>
<script>
$(document).ready(function(){
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('#modalEdit').modal();
});
</script>
I Need to pass the ID to the modal to get the info of the user from the DB.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2r2Lhtp
via IFTTT
Aucun commentaire:
Enregistrer un commentaire