⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Failed to save data



alejf06
  • profile picture
  • Member

Posted 28 January 2013 - 17:08 PM

Hello everyone,

I really apreciated your help, i am newbie from codeigniter and grocerycrud, and i can´t solve this problem with my data from i write in grocery where i have a field with long text, when i wrote in this field with the editor i have one error Failed to save data only if i write with html but if i write only text without returns.

I hope can help me, please!

Sorry for my english.

[attachment=452:problema.tiff]

davidoster
  • profile picture
  • Member

Posted 30 January 2013 - 10:07 AM

Is the database field of a related type of text?

alejf06
  • profile picture
  • Member

Posted 30 January 2013 - 15:16 PM

[quote name='David Oster' timestamp='1359540434' post='5350']
Is the database field of a related type of text?
[/quote]
Hi David, in my database i have the field how long text, i try with text but no work, i can't resolve this problem

davidoster
  • profile picture
  • Member

Posted 30 January 2013 - 23:52 PM

I suppose we need to see the code of the controller function and the structure of the table.

alejf06
  • profile picture
  • Member

Posted 31 January 2013 - 03:49 AM

Hi David,
tanks for your help!

This is my controller:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Heredamos de la clase CI_Controller */
class Productos extends CI_Controller {
function __construct()
{

parent::__construct();
/* Cargamos la base de datos */
$this->load->database();
/* Cargamos la libreria*/
$this->load->library('grocery_crud');
/* Añadimos el helper al controlador */
$this->load->helper('url');

}
function index()
{
/*
* Mandamos todo lo que llegue a la funcion
* administracion().
**/
redirect('productos/administracion');
}
/*
*
**/
function administracion()
{
try{
$this->load->view('header');
/* Creamos el objeto */
$crud = new grocery_CRUD();
/* Seleccionamos el tema */
$crud->set_theme('flexigrid');
/* Seleccionmos el nombre de la tabla de nuestra base de datos*/
$crud->set_table('Control');
/* Le asignamos un nombre */
$crud->set_subject('Control');

//el campo relacional
$crud->set_relation('id_um','UMed','Nombre');
//el campo relacional
$crud->set_relation('id_min','Ministracion','Ministracion');

/* Asignamos el idioma español */
$crud->set_language('spanish');

// subimos archivo
$crud->set_field_upload('Archivos','assets/uploads/files');


/* Aqui le decimos a grocery que estos campos son obligatorios */
$crud->required_fields(
'id_cumple',
'id_um',
'id_min',
'Fecha',
'Cumplimiento',
'Ministracion_next'

);
/* Aqui le indicamos que campos deseamos mostrar */
$crud->columns(
'id_cumple',
'id_um',
'id_min',
'Fecha',
'Cumplimiento',
'Ministracion_next',
'Archivos'
);

/* Generamos la tabla */
$output = $crud->render();

/* La cargamos en la vista situada en
/applications/views/productos/administracion.php */
$this->load->view('productos/administracion', $output);
$this->load->view('footer');
}catch(Exception $e){
/* Si algo sale mal cachamos el error y lo mostramos */
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
}


this is my view:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<head>

<h3>Cumplimiento</h3>
</head>

</div><!--fin del contenedor principal-->

<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
</head>
<body>

<div>
<?php echo $output; ?>
</div>
</body>
</html>


and my sql

CREATE TABLE IF NOT EXISTS `Control` (
`id_cumple` int(10) NOT NULL,
`id_um` int(10) NOT NULL,
`id_min` int(10) NOT NULL,
`Fecha` datetime NOT NULL,
`Cumplimiento` longtext COLLATE utf8_unicode_ci NOT NULL,
`Ministracion_netx` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
`Archivos` longblob NOT NULL,
PRIMARY KEY (`id_cumple`),
KEY `id_um` (`id_um`,`id_min`),
KEY `id_min` (`id_min`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `Control`
--
ALTER TABLE `Control`
ADD CONSTRAINT `Control_ibfk_2` FOREIGN KEY (`id_min`) REFERENCES `Ministracion` (`idmin`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `Control_ibfk_1` FOREIGN KEY (`id_um`) REFERENCES `UMed` (`id_med`) ON DELETE CASCADE ON UPDATE CASCADE;


can you help me?

victor
  • profile picture
  • Member

Posted 31 January 2013 - 07:24 AM

what version of the library and CI do you use?
try this:

function administracion()
{

$this->load->view('header');

$crud = new grocery_CRUD();

$crud->set_table('Control');

$output = $crud->render();
}

How result do you have now?

alejf06
  • profile picture
  • Member

Posted 31 January 2013 - 17:53 PM

[quote name='victor' timestamp='1359617066' post='5370']
what version of the library and CI do you use?
try this:

function administracion()
{

$this->load->view('header');

$crud = new grocery_CRUD();

$crud->set_table('Control');

$output = $crud->render();
}

How result do you have now?
[/quote]


Hi Victor, tanks for your help,

I write your code, but is the same problem, i can`t write with html and return.

My version of library is 1.3.3 and CI is 2.1.2

victor
  • profile picture
  • Member

Posted 31 January 2013 - 19:15 PM

try update Codeigniter to the latest version.
and try reinstall GC.
sorry for my English