Estou passando tudo certo. Tanto na id da div, quanto no data pra do botão pra abrir o modal. Ele puxa todos os outros, menos esses 2 ( escola e perfil ).
JS:
$(’#AlterarCadUserModal’).on(‘show.bs.modal’, function (event) {
var button = $(event.relatedTarget) // Botão que acionou o modal
var idalt = button.data(‘whatever-id’)
var useralt = button.data(‘whatever-user’)
var loginalt = button.data(‘whatever-login’)
var perfilalt = button.data(‘whatever-perfil’)
var escolaalt = button.data(‘whatever-escola’)
var statusalt = button.data(‘whatever-status’)
var modal = $(this)
modal.find(’.modal-title’).text(‘Modificar Usuário’)
modal.find(’#idalt_user’).val(idalt)
modal.find(’#nomealt_user’).val(useralt)
modal.find(’#loginalt_user’).val(loginalt)
modal.find(’#perfilalt_user’).val(perfilalt)
modal.find(’#escolaalt_user’).val(escolaalt)
modal.find(’#statusalt_user’).val(statusalt)
})
Botão:
<button type=“button” class=“btn btn-alterar btn-sm fa fa-pencil-square-o” data-toggle=“modal” data-target="#AlterarCadUserModal"
data-whatever-id="{{$usuario->id_usuario}}" data-whatever-user="{{$usuario->nome}}"
data-whatever-login="{{$usuario->login}}" data-whatever-escola="{{$usuario->escola_fk}}" data-whatever-status="{{$usuario->ativo}}"
Alterar
Modal:
<div class="modal-dialog modal-lg" role="document"> <div class="modal-content"> <div class="b_edit_modalHeader"> <div class="modal-header"> <h5 class="modal-title" id="AlterarCadUserModalLabel">Alterar</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Fechar"> <span aria-hidden="true">×</span> </button> </div> </div> <div class="modal-body"> <form class="form-horizontal" method="POST" action="{{action('UsuarioController@store')}}"> @csrf <div class="form-group row"> <div class="col-sm-6"> <label class="control-label">Nome</label> <input class="form-control" type="hidden" name="idalt" id="idalt_user" required> <input class="form-control" type="text" name="nomealt" id="nomealt_user" placeholder="Digite o nome" required> </div> <div class="col-sm-6"> <label class="control-label">Escola/Setor</label> <select class="selectescolaalt" tabindex="-1" name="escolaalt" id="escolaalt_user"> @foreach ($escolas as $escola) <option value="{{$escola->id_escola}}">{{$escola->nome}}</option> @endforeach </select> <p></p> </div> <div class="col-sm-6"> <label class="control-label">Login</label> <input class="form-control" type="text" name="loginalt" id="loginalt_user" placeholder="Digite o login" required> </div> <div class="col-sm-3"> <label class="control-label">Perfil</label> <select class="selectperfilalt" name="perfilalt" id="perfilalt_user"> @foreach ($perfis as $perfil) <option value="{{$perfil->idPerfil}}">{{$perfil->nome}}</option> @endforeach </select> </div> <div class="col-sm-3"> <label class="control-label">Status</label> <select class="form-control" name="statusalt" id="statusalt_user" > <option value="1">Ativo</option> <option value="0">Inativo</option> </select> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" id="reset" data-dismiss="modal"><i class="fa fa-times"> Cancelar</i></button> <button type="submit" class="btn btn-primary"><i class="fa fa-floppy-o"> Salvar</i></button> </div> </form> </div> </div> </div>