⚠ 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

callback_insert don´t redirect



Natacha AR
  • profile picture
  • Member

Posted 05 August 2016 - 17:13 PM

In past versions of grocery crud when I add new information in database then I save the data, automaticaly redirect me at main view and show me the data is  saved successful, now with the bootstrap theme does not do it, 

just show me this

 

{"success":true,"insert_primary_key":38,"success_message":"

Sus datos han sido guardados correctamente. Editar Cursos<\/a> o Volver a la lista<\/a><\/p>","success_list_url":"http:\/\/redsocial\/index.php\/back\/control\/cursos\/success\/38"}

 

and I don´t know what I do. Any help please!!
 

This is my code:

$crud = new grocery_CRUD ();

		$crud->set_theme ( 'bootstrap' ); //datatables
                //titulo del boton add y de la pagina add upd
		$crud->set_subject ( 'Cursos' );
                $crud->set_table ( 'cursos' );  //Cursos
                
                //Etiqueta de la columna
		$crud->display_as ( 'Generacion', 'Generaci&oacute;n' );		
		$crud->display_as ( 'Id_Tipo_Curso', 'Tipo de Curso' );
		$crud->display_as ( 'Nombre_Sede', 'Nombre de la Sede' );
		$crud->display_as ( 'Id_Sede', 'Sede' );
                
                $crud->columns('Generacion', 'Id_Tipo_Curso','Id_Sede','Alumnos');
                
		$crud->set_relation('Id_Tipo_Curso','tipos_cursos','Tipo_Curso');
		$crud->set_relation('Id_Sede','sedes','Nombre_Sede');
		
                $crud->add_fields('Generacion','Id_Tipo_Curso','Id_Sede');
		$crud->edit_fields('Generacion','Id_Tipo_Curso','Id_Sede');

		$crud->order_by('Generacion');
		
		//Validaciones
		$crud->required_fields ( 'Generacion','Id_Tipo_Curso','Id_Sede');
		
                $crud->callback_insert(array($this,'inserta_curso'));
		$crud->callback_update(array($this,'actualiza_curso'));
		$crud->callback_delete(array($this,'borra_curso'));
		$crud->callback_column('Alumnos',array($this,'cuenta_alumnos'));
                
		$output = $crud->render ();

My function callback_insert

public function inserta_curso($post_array, $primary_key){
            	$this->load->model('modelo_alumnos');
		if(!$this->modelo_alumnos->existe_curso($post_array['Generacion'],$post_array['Id_Tipo_Curso'],$post_array['Id_Sede'])){
			$this->db->insert('cursos',$post_array);
                        return true;
		} else {
			return false;
		}
	}

Natacha AR
  • profile picture
  • Member

Posted 05 August 2016 - 19:05 PM

In my case the button save and go back to the list and cancel not working, only work save, but breaks...in my project I used a bootstrap template and grocery crud bootstrap theme, maybe they are some conflict with this??


Natacha AR
  • profile picture
  • Member

Posted 05 August 2016 - 19:22 PM

I found the problem, they are conflict with bootstrap template and the grocery crud bootstrap theme, any advice because I need use both, and I don´t know how to fix