⚠ 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

using a callback throws a "Call to undefined method"



tuursw
  • profile picture
  • Member

Posted 29 May 2020 - 07:18 AM

I am trying to get the callbacks working, but the examples in the documentation don't seem to work me, I am using Codeigniter 4 and the latest version of the CRUD framework BETA (v2.0.0-BETA)

 

when using callback_before_insert or callback_before_update ( as documented in the examples on https://www.grocerycrud.com/documentation/tutorial-using-callbacks/ ) I am getting errors that the method is unknown

 

Call to undefined method App\Libraries\GroceryCrud::callback_before_update()

$crud = new GroceryCrud();
$crud->setTable('fairs');
$crud->callback_before_insert(array($this,'set_slug_callback'));
$crud->callback_before_update(array($this,'set_slug_callback'));
$output = $crud->render();

function set_slug_callback($post_array, $primary_key) {
   if(empty($post_array['slug']))
   {
     $post_array['slug'] = url_title($post_array['fairName'], '-', TRUE);
   }
   return $post_array;
}

tuursw
  • profile picture
  • Member

Posted 29 May 2020 - 07:49 AM

edit: I am getting the same error when I am trying to create a relation $crud->set_relation('fair_id','fairs','fairName');

 

So it's probably not related to the callbacks but a more general problem...