Edit Form c / modal + Codeigniter

0

Good afternoon everyone,

I'm implementing an edit form (modal) that has an 'Edit' link and which when clicked opens a modal form. The big problem is that I am not able to assimilate the 'Edit' link and bring each BD line to the modal form to be edited. Thank you in advance.

<h1 class="title"><i class="fa fa-gears fa-2x"></i> PAINEL ADMINISTRATIVO / PRODUTOS </h1>
            <table class="table table-hover">
                <thead>
                  <tr>
                    <th>Produto</th>
                    <th>Tipo</th>
                    <th>R$ Preço</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                  <?php foreach($prod as $get_prods): ?>
                    <td><?php echo $get_prods->produto; ?></td>
                    <td><?php echo $get_prods->tipo; ?></td>
                    <td><?php echo $get_prods->preco; ?></td>
                    <td><a href="#box-editar" data-toggle="modal" data-target="#box-editar"><i class="fa fa-pencil "></i> Editar</a></td>
                  </tr>

                  <?php endforeach; ?>
                </tbody>
              </table><br />

        <!-- Modal editar -->
        <div class="modal fade" id="box-editar" tabindex="-1" role="dialog" aria-labelledby="boxLabel" aria-hidden="true">
          <div class="modal-dialog modal-md">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="boxLabel"><i class="fa fa-pencil "></i> Editar Produto</h4>
              </div>
              <div class="modal-body">

              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick='' data-dismiss="modal">Salvar alterações</button>
              </div>
            </div>
          </div>
        </div>
    
asked by anonymous 07.12.2016 / 21:21

1 answer

0

You must mount the form of editing, with the fields or create the same in the admin, make the call of the modal passing the information of the bank! e.g.

$('#idDoModalContent').load(base +'index.php/admin/Controller/Method' ,function(result){
  $('#idDoModalContent').html(result);
});
<div class="modal" id="idDoModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h4 class="modal-title">Resumo do Jogo</h4>
        </div>
        <div class="modal-body">
			<div class="row">
                <div class="col-xs-12" id="idDoModalContent">
                </div>
            </div>
        </div>
       	<div class="modal-footer">       	 
          <a href="#" data-dismiss="modal" class="btn btn-default">Fechar</a>
        </div>
      </div>
    </div>
</div>

Basically this would be it !!

    
07.12.2016 / 22:02