⚠ 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

Decimal values with problem on before_update callback



Romac

Romac
  • profile picture
  • Member

Posted 18 August 2013 - 02:26 AM

Guys, please i need your help!

 

   This is my problem:

 

 In my country (Brazil), the decimal separator is the comma ",", so:

 

$crud->callback_column('preco',array($this,'valueToReal'));

 

 

function valueToReal($value, $row)
{
    return 'R$ '.number_format($value, 2, ',', '.');    //$value.' €';
}

 

 

This show the values on correct format, ( 9.99 to R$ 9,99), and before update, i turn back the "."

 

$crud->callback_before_update(array($this,'checking_preco'));

 

 

function checking_preco($post_array,$primary_key)
{
    $post_array['preco'] = number_format($post_array['preco'],2,'.', '');
   
    return $post_array;
}

 

 

But, the value on $post_array['preco'] dont have the decimals!!!  "9,99" is only "9" on before_update!

 

Whats o going on? Where i wrong?

 

Sorry for my poor english, and thanks for your time. 

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 18 August 2013 - 09:13 AM

Hi there,

My query here is .. what is it you have an entry in the box while you are updating. I know you have 9,99 @column level. But while entering .. what is the value you setting.

Take a dump of the post from firebug and share / have a look @what is the real issue and where


Romac

Romac
  • profile picture
  • Member

Posted 18 August 2013 - 18:01 PM

Well, if i do a update directly on database with the value "9.99" it ok, when i list with grocery the display is ok, but on update they write "9". Without any modification on column by the user.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 19 August 2013 - 08:37 AM

well to reach to the proper solution on the same, take a dump of the post from firebug and share / have a look @what is the real issue and where. There we will atleast come to know as what is the value being posted.

Also if possible for you to take the dump of the post_array in your callback method .. if you can get the dump .. it will be easier to analyze and give u solution