⚠ 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

My callbacks don't work



kuaskada

kuaskada
  • profile picture
  • Member

Posted 18 November 2014 - 11:45 AM

Hello!

 

I've a problem with some callbacks in a controller.

 

My function in the controller:

 

function crud_cursos(){
$crud = new grocery_CRUD();
            $crud->set_theme('flexigrid');
            $crud->set_table('cursos');
            $crud->set_subject('curso')->set_language('spanish');
            $crud->columns('id_deporte_curso', 'fecha_inicio_curso', 'fecha_fin_curso', 'nivel_curso', 'inscritos_curso', 'max_inscritos_curso', 'estado_curso', 'id_monitor_curso', 'precio_curso');
            $crud->display_as('fecha_inicio_curso', 'Fecha de inicio')->display_as('fecha_fin_curso', 'Final del curso')->display_as('nivel_curso', 'Nivel')
                    ->display_as('inscritos_curso', 'Alumnos inscritos')->display_as('max_inscritos_curso', 'Número de plazas')->display_as('estado_curso', 'Estado')
                    ->display_as('id_monitor_curso', 'Monitor')->display_as('id_deporte_curso', 'Deporte')->display_as('precio_curso', 'Precio total');
            $crud->add_fields('fecha_inicio_curso', 'fecha_fin_curso', 'nivel_curso', 'max_inscritos_curso', 'id_deporte_curso', 'id_monitor_curso');
            $crud->edit_fields('fecha_inicio_curso', 'fecha_fin_curso', 'nivel_curso', 'inscritos_curso', 'max_inscritos_curso', 'id_deporte_curso', 'id_monitor_curso');


            $crud->set_relation('id_monitor_curso', 'usuarios', '{nombre_usuario} {apellido1_usuario} {apellido2_usuario}', array('tipo_usuario' => 'Monitor'));
            $crud->set_relation('id_deporte_curso', 'deportes', 'nombre_deporte');
            
            $crud->callback_after_insert(array($this, '_rellenar_url_curso'));
            $crud->callback_after_update(array($this, '_actualizar_url_curso'));
            
            $output = $crud->render();
}

When i add a course and click the button save or save and back, the course is added in the database but the callback doesn't work. If I comment the callbacks, the crud works fine.

I wrote on the callback:

var_dump($post_array);
die();

but don't happen anything. The crud doesn't call the callback function.

In others controllers i have some callbacks and work fine.

 

The console produce this output:

 

[attachment=862:error_crud_cursos.png]

 

 

Thanks and sorry for my poor english.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 18 November 2014 - 12:21 PM

well u checking on the wrong place - u rather should check up stuff on the network - i will recommend firebug ... where u check the output of the call in firebug ...

there u might be in a better position to check on the error output for the call..!!


kuaskada

kuaskada
  • profile picture
  • Member

Posted 18 November 2014 - 13:50 PM

Hi Amit!

 

I solved the problem with firebug. I changed one field to default value and I didn't change "$post_array['estado_curso']", and this field was NULL.

 

Why didn't show $post_array using var_dump($post_array) in the callback function?

 

Thank you very much... I had never used firebug ;)


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 18 November 2014 - 18:18 PM

welll Firebug is way better for debuging the chrome - i have experienced major developers using chrome - but i prefer Firebug anytime .. even for style debuging / fixing - its far better then chrome.

 

It should print var_dump ..but it would not print in the console of chrome / firebug but will be in response - there was an error that was returned.. and javascript @client end could not handle the exception so it hung there / failed to execute further - post var_dump .. if u wana see whats there - u need to kill it.. it should die else it might skip the output with redirects.


kuaskada

kuaskada
  • profile picture
  • Member

Posted 24 November 2014 - 11:34 AM

Hi!
 
From now on I will use firebug. I've been testing and I really like.
 
Thanks and sorry for the delay. I needed the help of a friend to translate.

Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 24 November 2014 - 14:55 PM

absolutely no worries.. i can understand.. and u might sometimes take help from Mr. Google. ..for translation :D