1
Hello,
I’m trying to pass some parameters to the controller, but I’m not getting it.
The following Code has been changed to load the contents of the tab clicked and display it in an input and texarea.
And it is working and loading correctly, as link this link.
Now I need that when changing anything and Submit done, the change be saved in the bank.
However, when I send the form, regardless of the ID I’m changing, I’m getting the following feedback:
UPDATE `nota` SET `titulo` = 'NOTA 5', `nota` = 'TEXTO NOTA 5', `usuario_nome` = 'Wagner Fillio', `usuario_id` = '1', `dt_alteracao` = 1481891781 WHERE `id` = '5'
This is because in memento I have 5 notes recorded in the comic.
See below for my view code
<?php
$classActive = "";
$divMenu = "";
$divPanel = "";
$this->db->order_by('id', 'asc');
$this->db->where('usuario_id', $this->session->userdata('id'));
$this->db->where('usuario_nome', $this->session->userdata('usuario_nome'));
$nota = $this->db->get('nota')->result_array();
$contador = 0;
foreach ($nota as $row) {
$classActive .= ($contador == 0) ? "active" : "inactive";
//$divMenu = "<li class=\"" . $classActive . "\"><a href=\"#" . $row['id'] . "\" data-toggle=\"tab\"><i class=\"\"></i>" . $row['titulo'] . "</a></li>";
$divPanel .= "
<div class=\"tab-pane " . $classActive . "\" id=\"" . $row['id'] . "\">
<div id=\"sample\" class=\"ruledpaper\">
<div class=\"form-group\" style=\"margin: 0px;\">
<div class=\"col-md-12\" style=\"padding:0px; background-color: #FFFCEE; font-size: 5px;\">
<input type=\"text\" class=\"form-control\" name=\"id\" value=\"" . $row['id'] . "\">
<input type=\"text\" class=\"form-control\" rows=\"14\" style=\"padding: 5px; border:0px; background-color: #fff6cc; font-size: 18px;\" name=\"titulo\" placeholder=\"Título\" value=\"" . $row['titulo'] . "\">
</div>
</div>
<hr style=\"margin: 0px;\" />
<div class=\"form-group\">
<div class=\"col-md-12\" style=\"padding:0px;\">
<textarea maxlength=\"60\" class=\"ruledpaper form-control\" rows=\"\" cols=\"\" style=\"padding: 5px; border:0px; min-height: 350px;\" name=\"nota\" placeholder=\"Digite o texto...\">" . $row['nota'] . "</textarea>
</div>
</div>
</div>
</div>";
$contador++;
}
?>
<form action="<?= base_url()?>admin/notas/salvar" id="" method="post" class="form-horizontal" >
<div class="row">
<div class="col-sm-8">
<div class="tab-content" style="width: 70%;">
<?php echo $divPanel; ?>
<div class="form-group">
<div class="box-header" style="padding-left: 17px">
<?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-primary btn-flat', 'content' => 'Salvar')); ?>
<?php echo form_button(array('type' => 'reset', 'class' => 'btn btn-warning btn-flat', 'content' => 'Limpar')); ?>
<?php echo anchor('admin/dashboard', 'Limpar', array('class' => 'btn btn-default btn-flat')); ?>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<ul class="nav tabs-vertical">
<?php foreach ($nota as $row){?>
<li class="">
<a href="#<?php echo $row['id'];?>" data-toggle="tab"> <i class=""></i> <?php echo $row['titulo'];?> </a>
</li>
<?php }?>
</ul>
</div>
</div>
</form>
Check out the controller
$id = $this->input->post('id');
$data['titulo'] = $this->input->post('titulo');
$data['nota'] = $this->input->post('nota');
$data['usuario_nome'] = $this->session->userdata('nome_usuario');
$data['usuario_id'] = $this->session->userdata('id');
$data['dt_alteracao'] = strtotime(date("d-m-Y H:i:s"));
$this->db->where('id',$id);
if($this->db->update('nota', $data)){
echo $this->db->last_query();
die();
redirect('admin/notas/index', $data);
}
else
{
redirect('admin/notas/index', $data);
}
Face, perfect. I’ll try the code better, but with that the problem has been solved. Thanks for the help!!!
– Wagner Fillio