I need to save in an array the text strings I have in several inputs that have been created dynamically, to send them to the controller and that it can insert them in the database.
// This would be the view
//ESTO ES EL CODIGO QUE GENERA LOS BOTONES DE AÑADIR Y BORRAR LOS INPUTS DINAMICOS
<script type="text/javascript">
icremento=0;
function crear(obj) {
icremento++;
field = document.getElementById('field');
contenedor = document.createElement('div');
contenedor.id = 'div'+icremento;
field.appendChild(contenedor);
boton = document.createElement('input');
boton.type = 'text';
boton.name = 'text'+icremento;
contenedor.appendChild(boton);
boton = document.createElement('input');
boton.type = 'button';
boton.value = 'Borrar';
boton.name = 'div'+icremento;
boton.onclick = function () {borrar(this.name)}
contenedor.appendChild(boton);
}
function borrar(obj) {
field = document.getElementById('field');
field.removeChild(document.getElementById(obj));
}
</script>
<input type="button" value="Crear caja de texto" onclick="crear(this)" class="btn btn-info"><br><br>
// THIS WOULD BE THE CONTROLLER
public function store(Request $request){
$date = Carbon::now();
$fecha = $date->format('d-m-Y');
$localizacion = $request->selector; //recibe informacion de un combobox
$observaciones = $request->comentarios; //recibe informacion de un
textarea
$tarea = new Tarea();
$tarea->fecha=$fecha;
$tarea->zona=$localizacion;
$tarea->observaciones=$observaciones;
$tarea->actividades="Y por qui pasaria el array de los datos de los inputs dinamicos";
$tarea->save();
return redirect('home');
}