⚠ 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

[SOLVED] Call to a member function callback_before_update() on a non-object



wenkhairu

wenkhairu
  • profile picture
  • Member

Posted 18 April 2012 - 03:45 AM

hi i have read doc for this one, and still have no answer, unable tu use callback_before_update()
it print Call to a member function callback_before_update() on a non-object
i'm using 1.1.8, here is my function so far


function daftar_anggota(){
$this->grocery_crud->set_table('anggota')
->set_subject('Daftar Anggota')
->columns('nama_anggota','email','no_telp','alamat')
->callback_edit_field('password',array($this,'_user_edit'))
->display_as('nama_anggota','Nama')
->display_as('email','Email')
->display_as('no_telp','No Telpon')
->display_as('alamat','Alamat')
->display_as('password','Password')
->display_as('user','Username')
->display_as('jenis_kelamin','Jenis Kelamin')
->display_as('tempat_lahir','Tempat Lahir')
->display_as('tgl_lahir','Tgl Lahir')
->display_as('status','Status')
->fields('nama_anggota','email','no_telp','alamat','user','password','jenis_kelamin','tempat_lahir','tgl_lahir','status')
->required_fields('nama_anggota','email','no_telp','alamat','user','password','jenis_kelamin','tempat_lahir','tgl_lahir','status')
->callback_before_insert(array($this,'_md5_pass'))
->callback_before_update(array($this,'_md5_pass'));
$this->_render_halaman($this->grocery_crud->render());
}

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 18 April 2012 - 06:11 AM

Sorry this is my mistake. It just that I forgot returning $this to all the callbacks methods. ( https://github.com/scoumbourdis/grocery-crud/issues/18 )

So you have two solutions:

The first is to just add all the callbacks differently so for example:


function daftar_anggota(){
$this->grocery_crud->set_table('anggota')
->set_subject('Daftar Anggota')
->columns('nama_anggota','email','no_telp','alamat')
->callback_edit_field('password',array($this,'_user_edit'))
->display_as('nama_anggota','Nama')
->display_as('email','Email')
->display_as('no_telp','No Telpon')
->display_as('alamat','Alamat')
->display_as('password','Password')
->display_as('user','Username')
->display_as('jenis_kelamin','Jenis Kelamin')
->display_as('tempat_lahir','Tempat Lahir')
->display_as('tgl_lahir','Tgl Lahir')
->display_as('status','Status')
->fields('nama_anggota','email','no_telp','alamat','user','password','jenis_kelamin','tempat_lahir','tgl_lahir','status')
->required_fields('nama_anggota','email','no_telp','alamat','user','password','jenis_kelamin','tempat_lahir','tgl_lahir','status');

$this->grocery_crud->callback_before_insert(array($this,'_md5_pass'));
$this->grocery_crud->callback_before_update(array($this,'_md5_pass'));

$this->_render_halaman($this->grocery_crud->render());
}


or just update your version with this commit: https://github.com/scoumbourdis/grocery-crud/commit/b54829e3ce42b7482ccec3ca77ff3f6f82ac46da