Edit Form c/ modal + Codeigniter

Asked

Viewed 429 times

0

Good afternoon to all,

I am implementing an edit form (modal) that has an 'edit' link and that when clicked opens a modal form. The big problem is that I am not able to assimilate the link 'Edit' and bring each line of the BD to the modal form to be edited. I thank you from now on.

<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>
  • select no bd is working well I can bring all the information, the big problem and with the link 'edit' q opens a modal, I am not able to assimilate this link with each line q comes from the bank to make the edition

1 answer

0

You must assemble the edit form, with the fields or create the same in admin, carry out the modal call by passing the database information! ex.:

$('#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 that would be!!

  • Tiago, for I am a beginner and at the same time you are enjoying the experience of using the IC looks only at what I was trying to do (I believe this was not successful), putting the whole modal structure inside the foreach and trying to use the same information of the select

  • if I can’t do with modal you have to do without msm :(

  • To load editing data on the modal screen along with its call, you will need to use Jquery, there is no escape from this!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.