⚠ 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 forum is read-only and soon will be archived. ⚠

how to use a personal helper in callback_column

callback_column helpers

  • Please log in to reply
No replies to this topic

#1 Kleenex



  • Members
  • Pip
  • 6 posts

Posted 18 November 2014 - 08:42 PM


I have this problem, I want to show number in a column as currency euro.

so, everything goes fine if inside the controller i put this:

    public function _formattaEURO($num) {
    $eu = number_format($num, 2, ',', '.');
    return "€ ".$eu;    

I can use this function inside callback_column:

$crud->callback_column('Prezzo_acquisto', array($this, '_formattaEURO')); 

...since I have to use very often this function, I'd like save it in a personal helper stored in application/helper


this is the helper, named 'euro_helper.php':

    function euro($num) {
    $eu = number_format($num, 2, ',', '.');
    return "€ ".$eu;   

in the controller I load it in this way:


and I believed that this was ok to use it in callback_column, like this:

$crud->callback_column('Prezzo_acquisto', array($this, 'euro')); 

...but this is what I get:



A PHP Error was encountered

Severity: Warning

Message: call_user_func() expects parameter 1 to be a valid callback, class 'articoli' does not have a method 'euro'

Filename: libraries/Grocery_CRUD.php

Line Number: 1757



So, I don't know how I can use a personal helper inside callback_column.

Thanks a lot for any reply ;-)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users