Each time I reload the page, it re-inserts the data, but when updating the page, the input left me with the information that had been entered, so I had to clean the input with js when loading the page.
$(document).ready(function () {
$(".txtClient").val("");
$(".txtNeed").val("");
$(".txtObjective").val("");
});
Home.ctp
<div class="row">
<div class="col-md-6">
<h1 id="h1IndexTitulo" class="lang" key="h1IndexTitulo">Laboratorio estrategico</h1>
<h4 class="lang" key="h4FirstTexto">
Diseñamos a través de las necesidades de <br> marca la mejor ruta
para cumplir con sus <br> objetivos y alcanzar resultados.
</h4>
<div class="col-md-6">
<?php
echo $this->Form->create('Need', array('class' => '', 'id' => 'msform'));
?>
<?php
echo $this->Form->input('client', array('label' => array('text' => "¿Para que marca vamos a trabahar?",
'key' => 'lblClient', 'class' => 'lang'), 'placeholder' => 'Dinos el nombre de tu empresa',
'class' => 'validador txtClient lang', 'key' => 'txtClient'));
echo $this->Form->input('need', array('label' => array('text' => "Escríbenos acerca de tu necesidad",
'key' => 'lblNeed', 'class' => 'lang'), 'placeholder' => 'Agradecemos nos detalles muy bien la necesidad, '
. 'es nuestro punto de partida para generar ideas quer fortalezcan la estrategia para resolverla.',
'rows' => '4', 'class' => 'validador txtNeed lang', 'key' => 'txtNeed', 'style' => 'resize: none;'));
echo $this->Form->input('objective', array('label' => array('text' => "¿Cuál es el objetivo?",
'key' => 'lblObjective', 'class' => 'lang'), 'placeholder' => 'Que se quiere alcanzar con la'
. 'solución de la necesidad, ¿Adquirir usuario? ¿Mejorar ventas? ¿Posicionar la marca? ... entre otros.'
. ' Agradecemos nos detalles muy bien el objetivo.', 'rows' => '4',
'class' => 'validador txtObjective lang', 'key' => 'txtObjective', 'style' => 'resize: none;'));
?>
<select class="selectpicker" data-width="fit">
<option data-content='<span class="flag-icon flag-icon-co" value="es"></span> Español'>Español</option>
<option data-content='<span class="flag-icon flag-icon-us" value="en"></span> English'>English</option>
</select>
<?php
$options = array(
'class' => 'lang',
'label' => 'Enviar y continuar',
'key' => 'btnFormNeed'
);
echo $this->Form->end($options);
?>
</div>
</div>
controller
public function home() {
return null;//Esto es para que no inserte cada vez que hago un cambio en la pagina
if ($this->request->is('post')) {
$this->loadModel('Need');
$this->Need->create();
if ($this->Need->save($this->request->data)) {
$this->Need->save(array(
'date' => date("Y/m/d")
));
}
}
}
This is an image of what the sql shows when reloading the page
As you can see when reloading it makes an insert of the data that had been previously entered, and I do not know how to send that.
Repeated data from the BD:
Each record has been for each time I update the page due to changes in the view or something else, either Js or Css.